Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DatePicker/TimePicker do not work with overlay popups. #7632

Closed
grokys opened this issue Feb 17, 2022 · 1 comment · Fixed by #7634
Closed

DatePicker/TimePicker do not work with overlay popups. #7632

grokys opened this issue Feb 17, 2022 · 1 comment · Fixed by #7634
Labels

Comments

@grokys
Copy link
Member

grokys commented Feb 17, 2022

Describe the bug

Trying to use a DatePicker/TimePicker when overlay popups is enabled results in a null reference exception.

To Reproduce
Steps to reproduce the behavior:

  1. On Windows, add OverlayPopups = true to the Win32PlatformOptions in ControlCatalog.NetCore
  2. Try to open a DatePicker/TimePicker
System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Avalonia.Controls
  StackTrace:
   at Avalonia.Controls.TimePickerPresenter.GetOffsetForPopup() in D:\projects\AvaloniaUI\Avalonia\src\Avalonia.Controls\DateTimePickers\TimePickerPresenter.cs:line 260
@grokys grokys added the bug label Feb 17, 2022
@grokys
Copy link
Member Author

grokys commented Feb 17, 2022

This is because when using overlay popups, a measure isn't carried out immediately (as is the case with a PopupRoot).

TimePicker opens the popup here and then immediately calls _presenter.GetOffsetForPopup(); which assumes that the template will have already been applied. With overlay popups, this is not the case.

grokys added a commit that referenced this issue Feb 17, 2022
When using overlay popups, a measure won't be done immediately on open, so the presenter template won't be set. Force a layout pass in this case. Also add a null check in `GetOffsetForPopup` just in case it does happen by some chance elsewhere.

Fixes #7632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant