Skip to content

TimePicker includes seconds when UseSeconds is false in 11.2.0-beta1&2 #17024

Open
@VisualMelon

Description

@VisualMelon

Describe the bug

When TimePicker.UseSeconds is false, the seconds component is still included in the resulting TimeSpan value. Further, the value defaults to the current time, so the seconds component can (and usually will) be non-zero by default. This makes this a behaviour breaking change.

To Reproduce

Easy to demo in the sandbox with this XAML alone: selecting a time with the TimePicker will update the TextBlock, and unless you are unlucky it will probably have a seconds component, revealing the breaking change.

  <StackPanel>
    <TimePicker x:Name="Picker" />
    <TextBlock Text="{Binding #Picker.SelectedTime}" />
  </StackPanel>

Sandbox example with simple fix in VisualMelon@6b6d24b

Expected behavior

In the specific example above, there should be no seconds component in the resulting TimeSpan (to address the breaking change). It's not entirely clear what the behaviour should be when e.g. changing the state of UseSeconds, as that's all new behaviour in the Beta, and I'm not familiar with how this is handled in other UI libraries. Additional discussion in #16079 (comment)

Avalonia version

11.2.0-beta2

OS

No response

Additional context

Only applies to the 11.2.0 betas which introduce TimePicker.UseSeconds

Metadata

Metadata

Assignees

No one assigned

    Labels

    bughelp-wantedA contribution from the community would be most welcome.regression

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions