Skip to content

[WB-1868.1] Dropdown: use Cell default styles #2659

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

Merged
merged 16 commits into from
Jun 24, 2025

Conversation

jandrade
Copy link
Member

@jandrade jandrade commented Jun 10, 2025

Summary:

This is a prep PR to simplify some of the dropdown styles before adding theming support to it.

  • Simplifies the OptionItem and ActionItem styles to just use the default CellCore styles.
  • Simplifies the OptionItem structure so the same layout can be reused by Single/MultiSelect and Listbox.
  • Adds a tabIndex prop to Cell so the component can work with different focus modes (needed for visual focus on Listbox/Combobox).
  • Updates the "check" icon color to be blue instead of offBlack.

Implementation plan:

  1. [WB-1868.1] Dropdown: use Cell default styles #2659
  2. Add theming support to wonder-blocks-dropdown package

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

Test plan:

Navigate to the Dropdown docs and verify that the stories look correct.

@jandrade jandrade self-assigned this Jun 10, 2025
Copy link

changeset-bot bot commented Jun 10, 2025

🦋 Changeset detected

Latest commit: ee7fb8d

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

This PR includes changesets to release 3 packages
Name Type
@khanacademy/wonder-blocks-cell Minor
@khanacademy/wonder-blocks-dropdown Minor
@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

Copy link
Contributor

github-actions bot commented Jun 10, 2025

Size Change: -432 B (-0.43%)

Total Size: 100 kB

Filename Size Change
packages/wonder-blocks-cell/dist/es/index.js 2.19 kB +7 B (+0.32%)
packages/wonder-blocks-dropdown/dist/es/index.js 16.2 kB -439 B (-2.64%)
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 2.99 kB
packages/wonder-blocks-announcer/dist/es/index.js 1.74 kB
packages/wonder-blocks-badge/dist/es/index.js 1.75 kB
packages/wonder-blocks-banner/dist/es/index.js 1.91 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.91 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 723 B
packages/wonder-blocks-button/dist/es/index.js 4.12 kB
packages/wonder-blocks-clickable/dist/es/index.js 2.67 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 4.94 kB
packages/wonder-blocks-grid/dist/es/index.js 1.24 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3.05 kB
packages/wonder-blocks-icon/dist/es/index.js 2.02 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 2.92 kB
packages/wonder-blocks-layout/dist/es/index.js 1.63 kB
packages/wonder-blocks-link/dist/es/index.js 1.64 kB
packages/wonder-blocks-modal/dist/es/index.js 4.61 kB
packages/wonder-blocks-pill/dist/es/index.js 1.31 kB
packages/wonder-blocks-popover/dist/es/index.js 4.32 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.48 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.09 kB
packages/wonder-blocks-styles/dist/es/index.js 467 B
packages/wonder-blocks-switch/dist/es/index.js 1.55 kB
packages/wonder-blocks-tabs/dist/es/index.js 3.67 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.51 kB
packages/wonder-blocks-testing/dist/es/index.js 985 B
packages/wonder-blocks-theming/dist/es/index.js 577 B
packages/wonder-blocks-timing/dist/es/index.js 1.37 kB
packages/wonder-blocks-tokens/dist/es/index.js 4.84 kB
packages/wonder-blocks-toolbar/dist/es/index.js 900 B
packages/wonder-blocks-tooltip/dist/es/index.js 6.42 kB
packages/wonder-blocks-typography/dist/es/index.js 1.55 kB

compressed-size-action

Copy link
Contributor

github-actions bot commented Jun 10, 2025

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

Metric Total
Captured snapshots 360
Tests with visual changes 1
Total stories 627
Inherited (not captured) snapshots [TurboSnap] 0
Tests on the build 360

Base automatically changed from tb-cell-2 to feature/tb-cell-dd June 13, 2025 19:53
@jandrade jandrade marked this pull request as ready for review June 18, 2025 17:11
@khan-actions-bot khan-actions-bot requested a review from a team June 18, 2025 17:11
@khan-actions-bot
Copy link
Contributor

khan-actions-bot commented Jun 18, 2025

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to pnpm-lock.yaml, .changeset/ninety-dodos-argue.md, .changeset/small-clouds-wash.md, .storybook/preview.tsx, packages/wonder-blocks-dropdown/package.json, packages/wonder-blocks-dropdown/tsconfig-build.json, packages/wonder-blocks-cell/src/util/types.ts, packages/wonder-blocks-dropdown/src/components/action-item.tsx, packages/wonder-blocks-dropdown/src/components/check.tsx, packages/wonder-blocks-dropdown/src/components/checkbox.tsx, packages/wonder-blocks-dropdown/src/components/combobox.tsx, packages/wonder-blocks-dropdown/src/components/listbox.tsx, packages/wonder-blocks-dropdown/src/components/option-item.tsx, packages/wonder-blocks-cell/src/components/internal/cell-core.tsx

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

Copy link
Contributor

github-actions bot commented Jun 18, 2025

npm Snapshot: Published

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

You can install the packages in frontend by running:

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

Packages can also be installed manually by running:

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

Copy link
Member

@beaesguerra beaesguerra left a comment

Choose a reason for hiding this comment

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

It's looking good, the styling improvements are great! Left some questions in the PR and chromatic!

Comment on lines +643 to +647
onMouseDown={(e) => {
// Prevents the combobox from losing focus when clicking
// on the option item.
e.preventDefault();
}}
Copy link
Member

Choose a reason for hiding this comment

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

Is the equivalent logic needed for keyboard interactions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I just moved that from option-item to this component directly to simplify the implementation (forgot to add a note here).

https://github.com/Khan/wonder-blocks/pull/2659/files#diff-38e10b1fd4a491d9c1d9de42989fb83e7da8ad1a88171f0976b73847b03ba2d7L281-L285

@@ -8,16 +8,12 @@ import {
border,
sizing,
} from "@khanacademy/wonder-blocks-tokens";
import {LabelMedium, LabelSmall} from "@khanacademy/wonder-blocks-typography";
import {LabelMedium} from "@khanacademy/wonder-blocks-typography";
Copy link
Member

Choose a reason for hiding this comment

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

Could we use the BodyText component? (not sure if you had plans for that later!)

Copy link
Member Author

Choose a reason for hiding this comment

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

good question! I had plans to add it in the next PR as this one was already including a bunch of changes, but I can add it here if you prefer.

Copy link
Member

Choose a reason for hiding this comment

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

In another PR is fine too :)

@@ -143,8 +139,6 @@ type DefaultProps = {
selected: OptionProps["selected"];
};

const StyledLi = addStyle("li");
Copy link
Member

Choose a reason for hiding this comment

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

Did we intend to remove using the li semantics for combobox option items?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah! I saw that it had this structure:

listbox
  > li
  > il

I changed it to use the correct semantics:

  listbox
    > option
    > option

Let me know if you see something off.

@khan-actions-bot khan-actions-bot requested a review from a team June 20, 2025 14:18
@jandrade jandrade requested a review from beaesguerra June 20, 2025 14:34
Copy link
Member

@beaesguerra beaesguerra left a comment

Choose a reason for hiding this comment

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

Looks great! 🚀

@jandrade jandrade merged commit 88c633a into feature/tb-cell-dd Jun 24, 2025
14 checks passed
@jandrade jandrade deleted the tb-dropdown-1 branch June 24, 2025 15:14
Copy link

codecov bot commented Jun 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (bb7eb76) to head (ee7fb8d).
Report is 1 commits behind head on feature/tb-cell-dd.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##   feature/tb-cell-dd   #2659   +/-   ##
==========================================
==========================================

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb7eb76...ee7fb8d. Read the comment docs.

🚀 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.

jandrade added a commit that referenced this pull request Jun 27, 2025
## Summary:
This PR includes the following commits:

Issue: WB-XXXX

## Test plan:
- [feature/tb-cell-dd] Trigger empty commit for creating integration branch PR
- [🔥AUDIT🔥] [WB-1958.1] Refactor Cell stories to use StateSheet (#2643)
- [WB-1958.2] Add theming support to Cell (#2644)
- [WB-1959] Add thunderblocks theme to CompactCell and DetailCell (#2657)
- [WB-1959.3] Cell layout refactor (#2661)
- [WB-1868.1] Dropdown: use Cell default styles (#2659)
- [WB-1868.2] Dropdown: Theming set up (#2675)
- [WB-1868.3] Add ThunderBlocks theme to dropdown (#2680)
- [feature/tb-cell-dd] Fix merge conflicts

[WB-1959]: https://khanacademy.atlassian.net/browse/WB-1959?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

Author: jandrade

Reviewers: beaesguerra

Required Reviewers:

Approved By: beaesguerra

Checks: ✅ 19 checks were successful, ⏹️  4 checks were cancelled, ⏭️  3 checks have been skipped

Pull Request URL: #2642
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.

3 participants