@rjsf/daisyui: the two date pickers duplicate the popup shell, and position it two different ways

Author: heath-freenomeCreated Sep 30, 2026Updated Sep 30, 2026
Labelsneeds triage

Prerequisites

  • I have searched the existing issues
  • I understand that providing a SSCCE example is tremendously useful to the maintainers.
  • I have read the documentation

What theme are you using?

daisyui

Version

7.x (v7 branch)

Current Behavior

Updated after #5356 extracted DatePickerCalendar: the calendar the two pickers draw is now one shared component, which makes this issue smaller and changes what it is about. What is still duplicated is the popup shell around that calendar, of which positioning is one part.

The shell

Both widgets repeat, verbatim, the role='presentation' container that takes containerRef and swallows a click, and an identical five-line footer holding an untranslated Done button:

typescript
<div className='p-3 flex justify-end border-t border-base-300'>
  <button type='button' className='btn btn-sm btn-primary' onClick={handleDone}>
    Done
  </button>
</div>

They differ only in the container's own positioning, below. So a change to the popup frame — the footer's wording going through translateString, the container gaining a role='dialog' and a label, focus being trapped while it is open — is two edits in two files, and lands wrong in one of them if they drift.

The deeper shape is one popup-shell component owning the container element, its ref, the click swallow and the footer, with each widget passing its body as children. That is also what would let the positioning question below be answered once.

The positioning

The two daisyui pickers position the same popup two different ways.

DateTimeWidget does it in CSS, in one class:

typescript
// packages/daisyui/src/widgets/DateTimeWidget/DateTimeWidget.tsx:239
className='absolute z-[100] mt-2 w-full max-w-xs bg-base-100 border border-base-300 shadow-lg rounded-box'

DateWidget does it in ~40 lines of imperative JavaScript (DateWidget.tsx:201-251): a renderCalendar() that reads getBoundingClientRect(), writes position, top, left and zIndex onto the container, and resize/scroll listeners that re-run it. After #5356 the two widgets share their popup state, every way out of it, the trigger and the value readers — positioning is the one remaining fork, and it is the larger of the two implementations.

Three things are wrong with the JS version independently of the duplication:

  • It runs in a passive effect, so the popup is painted at its CSS default position and then moved. Every open costs an extra layout and paint, and can show a visible jump.
  • The scroll listener is unthrottled, and renderCalendar forces layout with getBoundingClientRect() then writes styles. On a trackpad scroll that is a forced synchronous layout per event, 60–120×/second, for as long as the popup is open.
  • position: 'fixed' and zIndex: '99999' are written imperatively although the className already sets them (date-picker-popup fixed z-[99999] …), so two sources of truth for the popup's stacking. Note the inline writes are not simply dead: they are what still works if a consumer's Tailwind content globs do not scan @rjsf/daisyui, in which case none of those classes exist. That is the thing to decide deliberately rather than delete casually.

windowOf() in datePickerHooks.ts exists solely to serve this routine; with the positioner gone, so does half of that helper pair. (CALENDAR_MIN_WIDTH, which the positioner's clamp reads, is exported by DatePickerCalendar since #5356, so the footprint no longer has to be agreed by hand.)

Expected Behavior

One popup shell for both pickers, owning the container, the click swallow and the Done footer, with the body as children.

One positioner for both pickers: either DateWidget drops renderCalendar() and uses DateTimeWidget's CSS, or — if clamping the popup to the viewport edge is worth keeping — one positioner moves into the shared hook and DateTimeWidget gains it too. Whichever way, the initial placement happens before the first paint and the scroll handler is coalesced into a single requestAnimationFrame with a { passive: true } listener.

Steps To Reproduce

  1. Open a format: 'date' field's picker near the right edge of the viewport — DateWidget clamps it, DateTimeWidget does not.
  2. Open either and scroll: DateWidget recomputes its position on every scroll event; DateTimeWidget's follows the document because it is absolutely positioned.
  3. Profile a scroll with a DateWidget popup open: one forced layout per event.

Environment

markdown
- OS: any
- Node: any
- npm: any

Anything else?

Scope widened from "positioning" to "the popup shell" after #5356 extracted the calendar: positioning was the only fork when this was filed, and the shell is what the extraction left behind.

Raised out of review on #5356, which deleted the dead #date-picker-portal element and the getDocumentAndWindow() helper next to this code, and pointed what remains at the document the form is rendered into. Positioning was left alone there on purpose: it is a visual change with its own regression surface (edge placement, scroll containers, iframes) and did not belong in an accessibility and data-correctness change set.

Source: rjsf-team/react-jsonschema-form