Skip to content

Conversation

@jandrade
Copy link
Member

Summary:

  • Converted DropdownOpener in a function component.
  • Fixed DropdownOpener to propagate the onBlur event correctly. This change
    allows to update the focused styles when the opener is blurred.

Issue: https://khanacademy.atlassian.net/browse/WB-2152

Test plan:

  1. Navigate to the ActionMenu with custom opener story: /?path=/story/packages-dropdown-actionmenu--custom-opener
  2. Press tab until the focus is set on the opener.
  3. Press Enter or Space to open the menu.
  4. Press Escape to close it.
  5. Verify that the focus returns to the opener.
  6. Press tab again and ensure that the focus styles are removed from the opener.

BONUS: Verify that the SingleSelect and MultiSelect with custom opener
stories continue working as expected.

  • /?path=/story/packages-dropdown-singleselect--custom-opener
  • /?path=/story/packages-dropdown-multiselect--custom-opener

Juan Andrade added 2 commits November 13, 2025 12:05
…opagate onBlur event correctly. This change allows to update the focused styles when the opener is blurred.
@jandrade jandrade self-assigned this Nov 14, 2025
@changeset-bot
Copy link

changeset-bot bot commented Nov 14, 2025

🦋 Changeset detected

Latest commit: 0765115

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@khanacademy/wonder-blocks-dropdown Patch
@khanacademy/wonder-blocks-birthday-picker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@khan-actions-bot khan-actions-bot requested a review from a team November 14, 2025 16:59
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/heavy-roses-try.md, packages/wonder-blocks-dropdown/src/components/dropdown-opener.tsx

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Comment on lines +119 to +126
onBlur: onBlur
? (e: React.FocusEvent) => {
// This is done to avoid overriding a custom onBlur
// handler inside the children node
onBlur(e);
clickableChildrenProps.onBlur(e);
}
: clickableChildrenProps.onBlur,
Copy link
Member Author

Choose a reason for hiding this comment

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

note: This is the actual fix. The rest of the changes in this file is to convert the component into a function one.

Copy link
Member

Choose a reason for hiding this comment

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

Wow, that's a surprising find! It did not occur to me that onBlur could be the culprit.

@github-actions
Copy link
Contributor

Size Change: +1 B (0%)

Total Size: 109 kB

Filename Size Change
packages/wonder-blocks-dropdown/dist/es/index.js 19.4 kB +1 B (+0.01%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3 kB
packages/wonder-blocks-announcer/dist/es/index.js 1.74 kB
packages/wonder-blocks-badge/dist/es/index.js 2.02 kB
packages/wonder-blocks-banner/dist/es/index.js 2.01 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.92 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 755 B
packages/wonder-blocks-button/dist/es/index.js 4.25 kB
packages/wonder-blocks-card/dist/es/index.js 1.01 kB
packages/wonder-blocks-cell/dist/es/index.js 2.19 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.66 kB
packages/wonder-blocks-core/dist/es/index.js 2.48 kB
packages/wonder-blocks-data/dist/es/index.js 5.48 kB
packages/wonder-blocks-form/dist/es/index.js 6.2 kB
packages/wonder-blocks-grid/dist/es/index.js 1.24 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3.16 kB
packages/wonder-blocks-icon/dist/es/index.js 1.91 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 3.48 kB
packages/wonder-blocks-layout/dist/es/index.js 1.63 kB
packages/wonder-blocks-link/dist/es/index.js 1.52 kB
packages/wonder-blocks-modal/dist/es/index.js 6.99 kB
packages/wonder-blocks-pill/dist/es/index.js 1.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.3 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.1 kB
packages/wonder-blocks-styles/dist/es/index.js 464 B
packages/wonder-blocks-switch/dist/es/index.js 1.55 kB
packages/wonder-blocks-tabs/dist/es/index.js 3.71 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.25 kB
packages/wonder-blocks-testing/dist/es/index.js 978 B
packages/wonder-blocks-theming/dist/es/index.js 384 B
packages/wonder-blocks-timing/dist/es/index.js 1.37 kB
packages/wonder-blocks-tokens/dist/es/index.js 5.01 kB
packages/wonder-blocks-toolbar/dist/es/index.js 906 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.4 kB
packages/wonder-blocks-typography/dist/es/index.js 1.57 kB

compressed-size-action

@jandrade jandrade requested a review from nedredmond November 14, 2025 17:00
@github-actions
Copy link
Contributor

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (9afbdb9) and published all packages with changesets to npm.

You can install the packages in frontend by running:

./dev/tools/deploy_wonder_blocks.js --tag="PR2864"

Packages can also be installed manually by running:

pnpm add @khanacademy/wonder-blocks-<package-name>@PR2864

@github-actions
Copy link
Contributor

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-hkbwwtamxc.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 170
Tests with visual changes 0
Total stories 739
Inherited (not captured) snapshots [TurboSnap] 356
Tests on the build 441

Copy link
Member

@marcysutton marcysutton left a comment

Choose a reason for hiding this comment

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

Thanks for getting a fix together so quickly! I tested the stories you mentioned in the PR description manually and they still work. The styling is also improved on the ActionMenu story to only show one focus outline!

I wonder if we could add any test coverage or snapshots to verify the behavior in case it breaks sometime in the future?

Comment on lines +119 to +126
onBlur: onBlur
? (e: React.FocusEvent) => {
// This is done to avoid overriding a custom onBlur
// handler inside the children node
onBlur(e);
clickableChildrenProps.onBlur(e);
}
: clickableChildrenProps.onBlur,
Copy link
Member

Choose a reason for hiding this comment

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

Wow, that's a surprising find! It did not occur to me that onBlur could be the culprit.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants