Skip to content

Fix extra leading space in YearPicker#42

Closed
WZBbiao wants to merge 1 commit into
mbernson:mainfrom
WZBbiao:fix/year-picker-leading-space
Closed

Fix extra leading space in YearPicker#42
WZBbiao wants to merge 1 commit into
mbernson:mainfrom
WZBbiao:fix/year-picker-leading-space

Conversation

@WZBbiao

@WZBbiao WZBbiao commented Mar 2, 2026

Copy link
Copy Markdown

Problem

The year picker in the Popular talks view (used both in the tvOS inline view and the iOS toolbar) shows extra leading space before the year number. This was caused by the Label("Year", systemImage: "calendar") displaying both the calendar icon and the "Year" text. In .pickerStyle(.menu), this results in the text appearing as unwanted padding before the selected year.

Fix

Added .labelStyle(.iconOnly) to the Picker, which makes the label closure render only the calendar icon without the "Year" text. This removes the extra leading space while keeping the visual calendar indicator.

Fixes #40.

The YearPicker was using Label("Year", systemImage: "calendar") which
displayed both the icon and the "Year" text. In the menu picker style
(used on both tvOS inline and iOS toolbar), this caused extra leading
space to appear before the year number since the label text was rendered
alongside the selected value.

Applying .labelStyle(.iconOnly) to the Picker removes the text portion
of the Label, showing only the calendar icon. This eliminates the extra
leading space while keeping the visual calendar indicator.

Fixes mbernson#40.
@mbernson

mbernson commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Hi, thanks for submitting a PR. I tried your patch but unfortunately the unexpected spacing was still there.
I had another go at it, and after some Googling I figured that putting the Picker within a Menu is the structural fix. Like so:

ToolbarItem(placement: .topBarTrailing) {
    Menu {
        Picker("Year", selection: $year) { /* ... */ }
    } label: {
        Label("Year", systemImage: "calendar")
    }
}

Which is implemented in PR #51

@mbernson mbernson closed this Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Year picker for popular talks has extra leading space

2 participants