daisyUI's date pickers open from a combobox button into one popup element
Detect
- In your tests, a query for a daisyUI
DateWidgetorDateTimeWidgettrigger by thebuttonrole, or by[role="button"]andtabindex. - A query for the popup by the
presentationrole, or for adialoginside it. - CSS that styles the trigger
divor the popup's position, size, margin, padding, overflow orz-index. - A date widget rendered inside an ancestor with
overflow: hidden, such as a card or a collapse.
Change
The trigger:
- Both date widgets open their picker from a
<button type='button'>where they used a<div role='button' tabindex='0'>, so the field's label reaches the control it names through its ownhtmlFor, whicheverFieldTemplaterendered it. - The button has the
comboboxrole, asSelectWidget's trigger does, so it holds the date it displays as its value and isaria-invalidwhile its errors show. A query for either trigger by thebuttonrole should usecombobox. - The triggers show
ui:placeholderinstead ofschema.title. A field with no value, noui:placeholderand no title shows the translatedAriaDateLabelstring, "Select a date", where the button rendered empty. - Both triggers set
aria-describedby, so the description, errors and help around them are announced with the control.
Behaviour:
- Both date widgets honor
ui:disabledandui:readonly, which neither read before. The picker used to open from a disabled field and commit a new value over it. - A second press on the trigger, or on the label pointing at it, closes the picker and commits, where it closed and reopened in one gesture.
- Escape discards the date it was closed on, where the calendar kept it and the next close committed it. Escape also restores the month the stored value names.
- The Done button and
DateTimeWidget's time input label go throughtranslateStringasTranslatableString.DoneLabel("Done") andTranslatableString.TimeLabel("Time"), where they were hard-coded English (#5482). A table that maps every key needs them; see A translateString that maps every key needs the new TranslatableString keys.
The popup:
- Both widgets' popup is one element with the
date-picker-popupclass, and that element is thedialogthe trigger controls.DateWidget's was arole='presentation'wrapper, andDateTimeWidget's had no class. - Where the browser has native popovers it is a manual popover in the top layer, fixed below or above its trigger. Elsewhere it is
position: absolutejust below the trigger atz-index: 100, asDateTimeWidget's was. - Its position, size, margin, padding, overflow, overscroll behavior and text color, and that
z-index, are inline styles, so a stylesheet changing any of them on.date-picker-popupneeds!important(#5633).
Update queries:
-screen.getByRole('button', { name: 'When' });
-screen.getByRole('presentation');
+screen.getByRole('combobox', { name: 'When' });
+screen.getByRole('dialog');
Verify
- Both triggers are found by the
comboboxrole and the field's label. - The calendar shows in full inside cards and collapses in the browsers you support.
- A disabled or read-only date field does not open its picker.
If you can't preserve it
For DateWidget in Safari before 17 and Chrome before 114, an ancestor with overflow: hidden that doesn't scroll now cuts off the calendar and its Done button. The old fixed popup at z-index: 99999 escaped it. Give that ancestor overflow: visible, or override .date-picker-popup's position and z-index with !important.
Also read: