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

WB-1638.1: Fix clickable behavior on IconButton #2131

Merged
merged 2 commits into from
Dec 1, 2023

Conversation

jandrade
Copy link
Member

@jandrade jandrade commented Dec 1, 2023

Summary:

First part in a series of fixes to Popover.

I recently removed ClickableBehavior from IconButton because some APIs have
improved in the last years making it easier to implement the same behavior
without the need of ClickableBehavior.

Turns out that I missed a few things, and this PR fixes them:

  • Adds keyboard handlers to IconButton so that the click event can be
    triggered the same way with Enter and Space keys. By not doing this, it was causing that the Popover was being immediately re-opened if the user pressed Enter on the close button.

  • Prevents the button from displaying the pressed state after the user has
    pressed the button with a mobile device (sticky active state).

Issue: WB-1638

Test plan:

1. Normalized Enter and Space behavior:

In desktop, verify that the button can be pressed with Enter and Space keys
and that in both cases the button triggers the onClick callback only on key up.

Verify that a Popover is not immediately re-opened if the user presses Enter on the close button.

BEFORE

icon-button-enter-before.mov

AFTER

icon-button-enter-after.mov

2. Prevent sticky active state on mobile devices:

In mobile, verify that the button doesn't display the pressed state after the
user has pressed the button.

BEFORE

icon-button-sticky-pressed-before.MP4

AFTER

icon-button-sticky-pressed-after.MP4

@jandrade jandrade self-assigned this Dec 1, 2023
Copy link

changeset-bot bot commented Dec 1, 2023

🦋 Changeset detected

Latest commit: 63261f0

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

This PR includes changesets to release 8 packages
Name Type
@khanacademy/wonder-blocks-icon-button Patch
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-modal Patch
@khanacademy/wonder-blocks-popover Patch
@khanacademy/wonder-blocks-search-field Patch
@khanacademy/wonder-blocks-dropdown Patch
@khanacademy/wonder-blocks-tooltip 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
Copy link
Contributor

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/rich-bottles-hope.md, packages/wonder-blocks-icon-button/src/components/icon-button-core.tsx, packages/wonder-blocks-icon-button/src/components/icon-button.tsx, packages/wonder-blocks-icon-button/src/__tests__/__snapshots__/custom-snapshot.test.tsx.snap, packages/wonder-blocks-icon-button/src/components/__tests__/icon-button.test.tsx, packages/wonder-blocks-popover/src/components/__tests__/popover.test.tsx

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

@khan-actions-bot khan-actions-bot requested a review from a team December 1, 2023 16:35
Copy link
Contributor

github-actions bot commented Dec 1, 2023

Size Change: +148 B (0%)

Total Size: 90.9 kB

Filename Size Change
packages/wonder-blocks-icon-button/dist/es/index.js 3.21 kB +148 B (+5%) 🔍
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.69 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.72 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 1.13 kB
packages/wonder-blocks-button/dist/es/index.js 4.27 kB
packages/wonder-blocks-cell/dist/es/index.js 2.19 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.24 kB
packages/wonder-blocks-color/dist/es/index.js 1.15 kB
packages/wonder-blocks-core/dist/es/index.js 3.67 kB
packages/wonder-blocks-data/dist/es/index.js 6.33 kB
packages/wonder-blocks-dropdown/dist/es/index.js 12 kB
packages/wonder-blocks-form/dist/es/index.js 5.34 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-i18n/dist/es/index.js 4.54 kB
packages/wonder-blocks-icon/dist/es/index.js 1.06 kB
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.88 kB
packages/wonder-blocks-link/dist/es/index.js 2.54 kB
packages/wonder-blocks-modal/dist/es/index.js 5.04 kB
packages/wonder-blocks-pill/dist/es/index.js 1.03 kB
packages/wonder-blocks-popover/dist/es/index.js 4.33 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.51 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.55 kB
packages/wonder-blocks-spacing/dist/es/index.js 158 B
packages/wonder-blocks-switch/dist/es/index.js 2.06 kB
packages/wonder-blocks-testing/dist/es/index.js 3.94 kB
packages/wonder-blocks-theming/dist/es/index.js 1.21 kB
packages/wonder-blocks-timing/dist/es/index.js 1.78 kB
packages/wonder-blocks-toolbar/dist/es/index.js 862 B
packages/wonder-blocks-tooltip/dist/es/index.js 5.05 kB
packages/wonder-blocks-typography/dist/es/index.js 1.49 kB

compressed-size-action

Copy link

codecov bot commented Dec 1, 2023

Codecov Report

Merging #2131 (63261f0) into main (d2f6345) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2131   +/-   ##
=======================================
  Coverage   97.04%   97.05%           
=======================================
  Files         241      241           
  Lines       27995    28038   +43     
  Branches     2459     2381   -78     
=======================================
+ Hits        27169    27212   +43     
  Misses        826      826           
Files Coverage Δ
...ks-icon-button/src/components/icon-button-core.tsx 98.31% <100.00%> (+0.09%) ⬆️
...-blocks-icon-button/src/components/icon-button.tsx 100.00% <100.00%> (ø)

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 d2f6345...63261f0. Read the comment docs.

Copy link
Contributor

github-actions bot commented Dec 1, 2023

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (08f74b1) 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="PR2131"

Packages can also be installed manually by running:

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

Copy link
Contributor

github-actions bot commented Dec 1, 2023

A new build was pushed to Chromatic! 🚀

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

Chromatic results:

Metric Total
Captured snapshots 178
Tests with visual changes 2
Total stories 388
Inherited (not captured) snapshots [TurboSnap] 138
Tests on the build 316

Copy link
Member

@jeresig jeresig left a comment

Choose a reason for hiding this comment

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

Ahh - great! Thanks for the tests, as well.

@jandrade jandrade merged commit 9092363 into main Dec 1, 2023
13 checks passed
@jandrade jandrade deleted the icon-button-clickable-fix branch December 1, 2023 19:34
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