Skip to content

feat: add onFocusIn, onFocusOut, onEscape callback props#4259

Open
mxschll wants to merge 3 commits intomainfrom
dev-v3-schomax-dropdown-focus
Open

feat: add onFocusIn, onFocusOut, onEscape callback props#4259
mxschll wants to merge 3 commits intomainfrom
dev-v3-schomax-dropdown-focus

Conversation

@mxschll
Copy link
Member

@mxschll mxschll commented Feb 16, 2026

Description

  • This PR refactors adds onFocusIn, onFocusIn, onEscape event handlers to the Dropdown component
  • Renames onDropdownClose to onOutsideClick

See proposal RGJgABPXohP8 for more context.

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.35%. Comparing base (87a3e47) to head (413dba5).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4259   +/-   ##
=======================================
  Coverage   97.35%   97.35%           
=======================================
  Files         888      889    +1     
  Lines       26031    26057   +26     
  Branches     9411     9420    +9     
=======================================
+ Hits        25343    25369   +26     
- Misses        641      682   +41     
+ Partials       47        6   -41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mxschll mxschll requested a review from pan-kot February 17, 2026 21:24
@mxschll mxschll marked this pull request as ready for review February 17, 2026 21:25
@mxschll mxschll requested a review from a team as a code owner February 17, 2026 21:25
@mxschll mxschll removed the request for review from a team February 17, 2026 21:25
* must update the `open` prop to close the dropdown.
*/
onDropdownClose?: NonCancelableEventHandler<null>;
onOutsideClick?: NonCancelableEventHandler<null>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also include onEscape - like we have in the tooltip component?

Alternatively, we can parametrise onDropdownClose e.g. with some reason: "click-outside" | "escape".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can go with onEscape since it matches the tooltips API.

};

const focusOutHandler = (event: React.FocusEvent) => {
if (!event.relatedTarget || isOutsideDropdownContent(event.relatedTarget)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this check?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Internally we use onBlur which fires any time an element inside the dropdown content looses focus. So we check if the focus actually leaves the dropdown.

@mxschll mxschll changed the title feat: add onFocusIn and onFocusOut callback props feat: add onFocusIn, onFocusOut, onEscape callback props Feb 18, 2026
@mxschll mxschll force-pushed the dev-v3-schomax-dropdown-focus branch from f592fb5 to bee3915 Compare February 18, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants