Skip to content

[Bug] Selector, MultiSelector: pressing another field while the list is open sends focus back to the trigger #8952

Closed

Description

@duytbp

Description

With a Selector or MultiSelector list open, pressing another field closes the list (native popover="auto" light dismiss), and the hide handler then focuses the Selector's trigger unconditionally (useSelectorPresentation.ts:80-84). The press has already focused the other field, so focus is taken back from it. The user sees the field they pressed but is not in it, and the next key goes to the closed Selector: a letter changes its value through type-to-select.

DropdownMenu already guards this: on close it skips the focus return when focus has landed elsewhere (DropdownMenu.tsx:1027-1035). Selector and MultiSelector share useSelectorPresentation, which has no such check.

Expected: a light dismiss caused by a press on another focusable element leaves focus there. Escape, a choice in the list, or a press on nothing focusable still returns focus to the trigger.

Reproduction

import {useState} from 'react';
import {Selector, TextInput} from '@astryxdesign/core';

const options = [
  {value: 'apple', label: 'Apple'},
  {value: 'banana', label: 'Banana'},
  {value: 'cherry', label: 'Cherry'},
];

export function Repro() {
  const [fruit, setFruit] = useState<string | undefined>('apple');
  const [note, setNote] = useState('');
  return (
    <div style={{display: 'flex', gap: 120}}>
      <Selector label="Fruit" options={options} value={fruit} onChange={setFruit} />
      <TextInput label="Note" value={note} onChange={setNote} />
    </div>
  );
}
  1. Click "Fruit" to open the list.
  2. Click inside "Note". After the mouse down, focus is in "Note"; after the mouse up, the list closes and focus is back on the "Fruit" trigger.
  3. Type b. "Note" stays empty and "Fruit" changes to "Banana".

Astryx Version

@astryxdesign/[email protected], still present on main (14fc587)

Environment

Chromium 156 (Playwright, real mouse events). Any browser with native popover light dismiss.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions