Skip to content

ui v0.15.0

Choose a tag to compare

@github-actions github-actions released this 04 Dec 02:27
83d5fe3

Minor Changes

  • BREAKING CHANGE: Popovers, menus, selects, and comboboxes now render ordinary DOM elements instead of native top-layer popovers. Use the matching Portal component to escape clipping ancestors, and wrap each popup surface in its matching context component, as shown below. The context is required for inline rendering too. (#12170)

    Replace :popover-open styles with [data-state="open"]. Use [data-open] for styles that should remain during exit animations. Native beforetoggle and toggle events no longer fire.

    Place the surface context inside the Portal. Omit the Portal when the surface can remain inline.

    Popovers:

     import * as popover from '@remix-run/ui/popover'
    
     <popover.Context>
       <button mix={popover.anchor({ placement: 'bottom-start' })}>Open popover</button>
    -  <div mix={popover.surface({ open, onHide })}>Content</div>
    +  <popover.Portal>
    +    <popover.SurfaceContext>
    +      <div mix={popover.surface({ open, onHide })}>Content</div>
    +    </popover.SurfaceContext>
    +  </popover.Portal>
     </popover.Context>
    
     const surfaceStyle = css({
    -  '&:popover-open': { opacity: 1 },
    +  '&[data-state="open"]': { opacity: 1 },
     })

    Menus:

     import * as menu from '@remix-run/ui/menu'
    
     <menu.Context label="Menu">
       <button mix={menu.trigger()}>Open menu</button>
    -  <div mix={menu.popover()}>
    -    <div mix={menu.list()}>{/* Items */}</div>
    -  </div>
    +  <menu.Portal>
    +    <menu.PopoverContext>
    +      <div mix={menu.popover()}>
    +        <div mix={menu.list()}>{/* Items */}</div>
    +      </div>
    +    </menu.PopoverContext>
    +  </menu.Portal>
     </menu.Context>

    Selects no longer need a separate popover.Context. Replace it with select.PopoverContext around the popup surface:

    -import * as popover from '@remix-run/ui/popover'
     import * as select from '@remix-run/ui/select'
    
     <select.Context defaultLabel="Choose">
       <button mix={select.trigger()} />
    -  <popover.Context>
    -    <div mix={select.popover()}>
    -      <div mix={select.list()}>{/* Options */}</div>
    -    </div>
    -  </popover.Context>
    +  <select.Portal>
    +    <select.PopoverContext>
    +      <div mix={select.popover()}>
    +        <div mix={select.list()}>{/* Options */}</div>
    +      </div>
    +    </select.PopoverContext>
    +  </select.Portal>
     </select.Context>

    Comboboxes:

     import * as combobox from '@remix-run/ui/combobox'
    
     <combobox.Context>
       <input aria-label="Combobox" mix={combobox.input()} />
    -  <div mix={combobox.popover()}>
    -    <div mix={combobox.list()}>{/* Options */}</div>
    -  </div>
    +  <combobox.Portal>
    +    <combobox.PopoverContext>
    +      <div mix={combobox.popover()}>
    +        <div mix={combobox.list()}>{/* Options */}</div>
    +      </div>
    +    </combobox.PopoverContext>
    +  </combobox.Portal>
     </combobox.Context>

    DOM events, form ownership, and inherited styles follow the Portal destination.

    Popups no longer use the browser's top layer. Wrap your app content in an element with css({ isolation: 'isolate' }) so popups portaled to document.body appear above the app's z-index layers. For other layering setups, --rmx-layer-base can optionally raise the dialog and popup stack. It defaults to 0.

  • BREAKING CHANGE: Removed the selection flash from select, combobox and listbox, along with APIs for delaying selection feedback. (#12262)

    Select and Combobox

    select and combobox now show the chosen label while the popup starts closing, without waiting for a selection flash or label delay. Their change events fire after the displayed label and hidden form value update, so handlers can read the new value from FormData before closing finishes. combobox also selects the input text immediately.

    select.Context no longer accepts labelSwapDelayMs, since the selected label now updates immediately. Remove the prop when upgrading:

    -<select.Context defaultLabel="Select a type" labelSwapDelayMs={100} name="issueType">
    +<select.Context defaultLabel="Select a type" name="issueType">

    The data-select-flash and data-combobox-flash attributes are no longer set. Remove their CSS rules; existing selected and highlighted styles continue to apply:

     css({
       '&[aria-selected="true"]': { background: 'var(--selected-background)' },
    -  '&[data-select-flash]': { background: 'var(--flash-background)' },
    -  '&[data-combobox-flash]': { background: 'var(--flash-background)' },
     })

    Custom Listboxes

    listbox.Context no longer accepts flashSelection, selectionFlashAttribute or onSelectSettled. Move work from onSelectSettled into onSelect, which runs synchronously:

     <listbox.Context
       value={value}
       activeValue={activeValue}
    -  flashSelection
    -  onSelect={onSelect}
    -  onSelectSettled={(value, option) => saveSelection(value, option?.label)}
    +  onSelect={(value, option) => {
    +    onSelect(value, option)
    +    saveSelection(value, option?.label)
    +  }}
       onHighlight={onHighlight}
     >

    onSelect receives the new selection before your component renders the updated value. Use its value and option arguments for selection-dependent work, as above. If your old onSelectSettled callback read rendered DOM or form fields, wait for your component's update before reading them:

     <listbox.Context
       value={value}
       activeValue={activeValue}
    -  onSelect={(nextValue) => {
    +  onSelect={async (nextValue) => {
         value = nextValue
    -    handle.update()
    +    await handle.update()
    +    saveForm(new FormData(form))
       }}
    -  onSelectSettled={() => saveForm(new FormData(form))}
       onHighlight={onHighlight}
     >

    ListboxRef.select() and ListboxRef.selectActive() now return void instead of a promise. Listbox continues accepting selection and highlight requests while async callbacks run. If selecting closes your custom popup, use its open state to ignore further selection and highlight requests until it reopens. Set open = false before any awaited work:

     <listbox.Context
       value={value}
       activeValue={activeValue}
       onSelect={(nextValue) => {
    +    if (!open) return
    +    open = false
         value = nextValue
         void handle.update()
       }}
       onHighlight={(nextActiveValue) => {
    +    if (!open) return
         activeValue = nextActiveValue
         void handle.update()
       }}
     >

    select and combobox already handle this themselves.

    The data-listbox-flash attribute is no longer set. Remove its CSS rule; existing selected and highlighted styles continue to apply:

     css({
       '&[aria-selected="true"]': { background: 'var(--selected-background)' },
    -  '&[data-listbox-flash]': { background: 'var(--flash-background)' },
     })
  • animateExit() from @remix-run/ui/animation now accepts a callback (node) => config evaluated lazily when removal begins. This lets an exiting keyed element read updated parent state or measure the DOM at exit time instead of using potentially stale values from its last render, or return false, null, or undefined to skip the exit animation. (#12481)

    import { animateExit } from '@remix-run/ui/animation'
    
    function TabPanel() {
      return () => (
        <div
          key={activeTab}
          mix={animateExit((node) => {
            if (!shouldAnimate) return false
            return {
              opacity: 0,
              translate: `${direction * node.offsetWidth}px 0`,
              duration: 200,
              easing: 'ease-in',
            }
          })}
        />
      )
    }
  • Added @remix-run/ui/dialog with providers and mixins for accessible dialogs. (#12170)

Patch Changes

  • Keep IME candidate navigation and confirmation from selecting combobox options, dismissing the popup, or moving the active option. This includes Safari's confirming Enter key after composition ends. (#12415)

  • Fix anchor() positioning and scroll tracking for fixed-position floating surfaces inside positioned or transformed ancestors. (#12396)

  • Keep page scrolling locked across top-frame reloads while popovers, menus, selects or comboboxes are open. (#12260)

  • Escape and outside clicks now dismiss only the topmost popup in nested menus and dialogs. Keyboard input inside a nested popup no longer activates the parent menu, and closing a parent also closes its nested popups. (#12170)

  • Popovers no longer move focus back to the focusOnHide() target when another control outside the popover and its nested surfaces already holds focus, including when focus moves during exit animations. (#12470)

  • Pressing tab or shift+tab in an open Select now closes the popup and moves focus through the form instead of keeping it in the list. (#12170)

  • Timed toasts with countdown: true no longer report errors in browsers without CSS.registerProperty(), including Firefox 125–127. The countdown animation is skipped while timers, pausing, and dismissal continue normally. (#12370)

  • Bumped @remix-run/* dependencies: