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

SearchField: Add onKeyUp prop #2326

Merged
merged 1 commit into from
Sep 19, 2024
Merged

SearchField: Add onKeyUp prop #2326

merged 1 commit into from
Sep 19, 2024

Conversation

jandrade
Copy link
Member

Summary:

The SearchField component now accepts an onKeyUp prop that will be called when
the user releases a key while the input is focused.

This is to bring consistency with the other input components in the library and
also to allow for more flexibility when using the SearchField component.

Also took the opportunity to clear some of the SB argtype descriptions, as we no
longer need to duplicate them as of SB 8.0.

NOTE: This will be used as part of the Search page refactor.

Issue: FEI-5728

Test plan:

Verify that the unit tests pass.

@jandrade jandrade self-assigned this Sep 19, 2024
Copy link

changeset-bot bot commented Sep 19, 2024

🦋 Changeset detected

Latest commit: dd2759e

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-search-field Minor
@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 September 19, 2024 14:19
@khan-actions-bot
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/curly-bats-cover.md, __docs__/wonder-blocks-search-field/search-field.argtypes.ts, packages/wonder-blocks-search-field/src/components/search-field.tsx, packages/wonder-blocks-search-field/src/components/__tests__/search-field.test.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

npm Snapshot: Published

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

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2326"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2326

Copy link
Contributor

Size Change: 0 B

Total Size: 100 kB

ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.78 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.61 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 887 B
packages/wonder-blocks-button/dist/es/index.js 4.04 kB
packages/wonder-blocks-cell/dist/es/index.js 2.01 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.06 kB
packages/wonder-blocks-core/dist/es/index.js 3.44 kB
packages/wonder-blocks-data/dist/es/index.js 6.24 kB
packages/wonder-blocks-dropdown/dist/es/index.js 18 kB
packages/wonder-blocks-form/dist/es/index.js 6.18 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-i18n/dist/es/index.js 4.76 kB
packages/wonder-blocks-icon-button/dist/es/index.js 2.99 kB
packages/wonder-blocks-icon/dist/es/index.js 828 B
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.82 kB
packages/wonder-blocks-link/dist/es/index.js 2.28 kB
packages/wonder-blocks-modal/dist/es/index.js 5.36 kB
packages/wonder-blocks-pill/dist/es/index.js 1.65 kB
packages/wonder-blocks-popover/dist/es/index.js 4.87 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.3 kB
packages/wonder-blocks-switch/dist/es/index.js 1.94 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.64 kB
packages/wonder-blocks-testing/dist/es/index.js 1.13 kB
packages/wonder-blocks-theming/dist/es/index.js 693 B
packages/wonder-blocks-timing/dist/es/index.js 1.8 kB
packages/wonder-blocks-tokens/dist/es/index.js 2.1 kB
packages/wonder-blocks-toolbar/dist/es/index.js 827 B
packages/wonder-blocks-tooltip/dist/es/index.js 7.08 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

Metric Total
Captured snapshots 81
Tests with visual changes 0
Total stories 494
Inherited (not captured) snapshots [TurboSnap] 289
Tests on the build 370

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 good, thanks for making these improvements 🎉

@@ -1,6 +1,5 @@
export default {
clearAriaLabel: {
description: `ARIA label for the clear button. Defaults to "Clear search".`,
Copy link
Member

Choose a reason for hiding this comment

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

praise: Thanks for cleaning this up!

I will also start removing descriptions from story argtypes as I go along so we can rely on the prop docs to avoid duplication 😄

/**
* Called when a key is released.
*/
onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => unknown;
Copy link
Member

Choose a reason for hiding this comment

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

question: I noticed we often deconstruct the specific props before applying it to the underlying element. Do we do that so that the remaining otherProps will usually be the aria props? Are there any drawbacks to letting other props be part of the otherProps?

Here's an example where we do that with the other event handlers:

onClick,
onChange,
onFocus,
onBlur,
...otherProps

Copy link
Member Author

Choose a reason for hiding this comment

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

That's correct, we use that for aria props, and also for letting other valid attributes be injected in the inner node. I don't think there are drawbacks with that logic.... the only thing is that TS would complain, but this can be fixed by adding the missing props, like the one included here :).

@jandrade jandrade merged commit 659a031 into main Sep 19, 2024
14 checks passed
@jandrade jandrade deleted the search-field-keyup branch September 19, 2024 17:49
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.

3 participants