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

Dropdown: Accessbility - cannot tab out of editable dropdown with clear icon #7710

Closed
immieowen opened this issue Feb 17, 2025 · 3 comments · Fixed by #7714
Closed

Dropdown: Accessbility - cannot tab out of editable dropdown with clear icon #7710

immieowen opened this issue Feb 17, 2025 · 3 comments · Fixed by #7714
Assignees
Labels
Component: Accessibility Issue or pull request is related to WCAG or ARIA
Milestone

Comments

@immieowen
Copy link

immieowen commented Feb 17, 2025

Describe the bug

When focused on a Dropdown in primereact v10 with the editable prop, it becomes impossible to shift+tab to move focus back to the previous element. If you use editable and showClear props, you cannot tab forward either.

Reproducer

N/A - stackblitz has primereact v9, which does not have this bug.

System Information

react 19.0.0
primereact 10.9.2

Steps to reproduce the behavior

In primereact 10.9.2, render the following dropdown - you cannot tab or shift+tab to move focus away from the dropdown once you're focused within it (except by selecting an option, which returns focus to the start of the page, as per #6873 )

function App() {
  const [selectedCity, setSelectedCity] = useState(null);
  const cities = [
    { name: 'New York', code: 'NY' },
    { name: 'Rome', code: 'RM' },
    { name: 'London', code: 'LDN' },
    { name: 'Istanbul', code: 'IST' },
    { name: 'Paris', code: 'PRS' },
  ];

  return (
    <div className="card flex justify-content-center">
      <input placeholder="Shift + tab to here" />
      <Dropdown
        value={selectedCity}
        onChange={(e) => setSelectedCity(e.value)}
        options={cities}
        optionLabel="name"
        editable
        showClear
        placeholder="Select a City"
      />
      <input placeholder="Tab to here" />
    </div>
  );
}

Shift+tab being broken is also visible in the docs example. If you tab into the editable dropdown, or click on it, you cannot use shift+tab to move focus to the previous element - https://primereact.org/dropdown/#editable

Expected behavior

Should be able to shift+tab to move focus back from an editable Dropdown, and should be able to tab forward from an editable Dropdown with a clear icon.

@immieowen immieowen added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Feb 17, 2025
@melloware
Copy link
Member

Similar to: #7613

cc @akshayaqburst

@melloware melloware added Component: Accessibility Issue or pull request is related to WCAG or ARIA and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Feb 17, 2025
@melloware melloware added this to the 10.9.3 milestone Feb 17, 2025
@akshayaqburst
Copy link
Contributor

@melloware Working on this now. Thanks,

@akshayaqburst
Copy link
Contributor

@melloware I was not able to fix the focus trap issue. I have disabled clearIcon focus when editable mode is on. When I checked Stackoverflow and other open forums like Claude, it suggested me so.

Some finding from internet -

If tab navigation gets stuck when there's a clear icon inside an input box, there are a few common reasons this might happen:

  1. The clear icon might be a clickable element (button) that's capturing the tab focus:

// Problematic implementation

× // This creates a tab stop
  1. If the clear icon is absolutely positioned within the input wrapper, it might inadvertently be in the tab order.

Here's how to fix it:

Add tabIndex={-1} to the clear button to remove it from tab order:

×
  1. Best practice solution combining both accessibility and proper tab behavior:
{/* clear logic */}} >×

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Accessibility Issue or pull request is related to WCAG or ARIA
Projects
None yet
3 participants