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

fix: Add keyboard a11y for table filters #48894

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

Ke1sy
Copy link
Contributor

@Ke1sy Ke1sy commented May 13, 2024

中文版模板 / Chinese template

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Internationalization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Workflow
  • Other (about what?)

🔗 Related issue link

close #37508

💡 Background and solution

📝 Changelog

Added keyboard accessibility for table filters.
Installed react-focus-lock package to lock the focus inside the flter dropdown.

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

Copy link

stackblitz bot commented May 13, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

Copy link
Contributor

github-actions bot commented May 13, 2024

Preview is ready

Copy link
Contributor

  • 🚨 Please fill changelog in the PR

    • Write with a developer-oriented perspective and narrative method, without describing the details of the repair
    • Describing the problem and the impact on the developer
    • describing the user-first site problem, not your solution
    • Refer: https://ant.design/changelog#501
  • 🚨 请填写 PR 中的 changelog

    • 请用面向开发者的角度叙述方式撰写,不描述修复细节
    • 描述问题和对开发者的影响
    • 描述用户第一现场的问题,而非你的解决方式
    • 参考:https://ant.design/changelog-cn#501

Copy link
Contributor

github-actions bot commented May 13, 2024

👁 Visual Regression Report for PR #48894 Passed ✅

🎯 Target branch: master (072afcd)
📖 View Full Report ↗︎

🎊 Congrats! No visual-regression diff found.

@Ke1sy Ke1sy marked this pull request as ready for review May 13, 2024 12:17
@Ke1sy Ke1sy closed this May 13, 2024
@Ke1sy Ke1sy reopened this May 13, 2024
@Ke1sy Ke1sy marked this pull request as draft May 13, 2024 14:37
Copy link

codesandbox-ci bot commented May 14, 2024

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Copy link

codecov bot commented May 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (072afcd) to head (2c91191).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master    #48894   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          745       745           
  Lines        12976     13023   +47     
  Branches      3400      3411   +11     
=========================================
+ Hits         12976     13023   +47     

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

@Ke1sy Ke1sy marked this pull request as ready for review May 14, 2024 15:00
Copy link

socket-security bot commented May 15, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@@ -72,6 +72,9 @@ if (process.env.RUN_ENV === 'PRODUCTION') {
new DuplicatePackageCheckerPlugin({
verbose: true,
emitError: true,
exclude(instance) {
return instance.name === 'react-is';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added this to resolve the issue: The rc-util uses the version of react-is@^18.2.0 while the react-focus-lock > prop-types uses "react-is": "^16.13.1" (Allow react-is ^17 as dependency · Issue #354 · facebook/prop-types ), this throws an error on npm run dist.
image

Copy link
Member

Choose a reason for hiding this comment

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

This duplicated package will increase bundle size significantly.

图片

@Ke1sy Ke1sy marked this pull request as draft May 15, 2024 10:36
onDeactivation={() => {
triggerBtnRef.current?.focus();
}}
autoFocus={false}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I replaced this with focusFirstFocusableElement function, because there are some issues on the page http://localhost:8001/components/table where there are a lot of components, and focus is called too fast before dropdown is rendered, it results in a page to be scrolled to the top. We need at least zero timeout here, but react-focus-lock doesn't allow to add it.

@@ -537,15 +604,29 @@ function FilterDropdown<RecordType>(props: FilterDropdownProps<RecordType>) {
getPopupContainer={getPopupContainer}
placement={direction === 'rtl' ? 'bottomLeft' : 'bottomRight'}
rootClassName={rootClassName}
destroyPopupOnHide
Copy link
Contributor Author

@Ke1sy Ke1sy May 15, 2024

Choose a reason for hiding this comment

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

The content inside menu is not rerendered, so I cannot pass visible to FocusLock to set the disabled prop, as it doesn't update component, this is the only way to run the onDeactivation callback

@Ke1sy Ke1sy changed the title Add keyboard a11y for table filters fix: Add keyboard a11y for table filters May 15, 2024
@Ke1sy Ke1sy closed this May 16, 2024
@Ke1sy Ke1sy reopened this May 16, 2024
@Ke1sy Ke1sy marked this pull request as ready for review May 16, 2024 12:47
@Ke1sy
Copy link
Contributor Author

Ke1sy commented May 16, 2024

@afc163 @zombieJ @MadCcc Please, review my PR. Thanks!

@kiner-tang kiner-tang requested review from zombieJ and MadCcc May 16, 2024 12:51
Copy link

socket-security bot commented May 23, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/typescript@5.4.5 None 0 32.4 MB typescript-bot

🚮 Removed packages: npm/@ant-design/compatible@5.1.3, npm/@ant-design/happy-work-theme@1.0.0, npm/@ant-design/tools@18.0.2, npm/@antv/g6@4.8.24, npm/@babel/eslint-plugin@7.24.5, npm/@biomejs/biome@1.7.3, npm/@codesandbox/sandpack-react@2.13.10, npm/@dnd-kit/core@6.1.0, npm/@dnd-kit/modifiers@7.0.0, npm/@dnd-kit/sortable@8.0.0, npm/@dnd-kit/utilities@3.2.2, npm/@emotion/react@11.11.4, npm/@emotion/server@11.11.0, npm/@ianvs/prettier-plugin-sort-imports@4.2.1, npm/@madccc/duplicate-package-checker-webpack-plugin@1.0.0, npm/@microflash/rehype-figure@2.1.0, npm/@npmcli/run-script@8.1.0, npm/@octokit/rest@20.1.1, npm/@qixian.cs/github-contributors-list@2.0.1, npm/@size-limit/file@11.1.4, npm/@stackblitz/sdk@1.10.0, npm/@testing-library/dom@10.1.0, npm/@testing-library/jest-dom@6.4.5, npm/@testing-library/react@15.0.7, npm/@testing-library/user-event@14.5.2, npm/@types/adm-zip@0.5.5, npm/@types/ali-oss@6.16.11, npm/@types/cli-progress@3.11.5, npm/@types/fs-extra@11.0.4, npm/@types/gtag.js@0.0.19, npm/@types/http-server@0.12.4, npm/@types/inquirer@9.0.7, npm/@types/isomorphic-fetch@0.0.39, npm/@types/jest-axe@3.5.9, npm/@types/jest-environment-puppeteer@5.0.6, npm/@types/jest-image-snapshot@6.4.0, npm/@types/jest@29.5.12, npm/@types/jquery@3.5.30, npm/@types/jsdom@21.1.6, npm/@types/lodash@4.17.4, npm/@types/minimist@1.2.5, npm/@types/node@20.12.12, npm/@types/nprogress@0.2.3, npm/@types/ora@3.2.0, npm/@types/pixelmatch@5.2.6, npm/@types/pngjs@6.0.5, npm/@types/prismjs@1.26.4, npm/@types/progress@2.0.7, npm/@types/qs@6.9.15, npm/@types/react-copy-to-clipboard@5.0.7, npm/@types/react-dom@18.3.0, npm/@types/react-highlight-words@0.16.7, npm/@types/react-resizable@3.0.7, npm/@types/react@18.3.2, npm/@types/semver@7.5.8, npm/@types/spinnies@0.5.3, npm/@types/tar@6.1.13, npm/@types/throttle-debounce@5.0.2, npm/@types/warning@3.0.3, npm/@typescript-eslint/eslint-plugin@7.10.0, npm/@typescript-eslint/parser@7.10.0, npm/adm-zip@0.5.12, npm/ali-oss@6.20.0, npm/antd-img-crop@4.22.0, npm/antd-style@3.6.2, npm/antd-token-previewer@2.0.8, npm/axios@1.7.2, npm/cheerio@1.0.0-rc.12, npm/circular-dependency-plugin@5.2.2, npm/cli-progress@3.12.0, npm/cross-env@7.0.3, npm/cross-fetch@4.0.0, npm/crypto@1.0.1, npm/dekko@0.2.1, npm/dumi-plugin-color-chunk@1.1.0, npm/dumi@2.3.4, npm/esbuild-loader@4.1.0, npm/eslint-config-airbnb@19.0.4, npm/eslint-config-prettier@9.1.0, npm/eslint-import-resolver-typescript@3.6.1, npm/eslint-plugin-compat@4.2.0, npm/eslint-plugin-import@2.29.1, npm/eslint-plugin-jest@28.5.0, npm/eslint-plugin-jsx-a11y@6.8.0, npm/eslint-plugin-lodash@7.4.0, npm/eslint@8.57.0, npm/rc-cascader@3.26.0, npm/rc-checkbox@3.3.0, npm/rc-collapse@3.7.3, npm/rc-dialog@9.4.0, npm/rc-drawer@7.1.0, npm/rc-dropdown@4.2.0, npm/rc-field-form@2.0.1, npm/rc-image@7.6.0, npm/rc-input-number@9.1.0, npm/rc-input@1.5.1, npm/rc-mentions@2.13.1, npm/rc-menu@9.14.0, npm/rc-motion@2.9.1, npm/rc-notification@5.4.0, npm/rc-pagination@4.0.4, npm/rc-picker@4.5.0, npm/rc-progress@4.0.0, npm/rc-rate@2.12.0, npm/rc-resize-observer@1.4.0, npm/rc-segmented@2.3.0, npm/rc-select@14.14.0, npm/rc-slider@10.6.2, npm/rc-steps@6.0.1, npm/rc-switch@4.1.0, npm/rc-table@7.45.6, npm/rc-tabs@15.1.0, npm/rc-textarea@1.7.0, npm/rc-tooltip@6.2.0, npm/rc-tree-select@5.21.0, npm/rc-tree@5.8.7, npm/rc-upload@4.5.2, npm/rc-util@5.41.0, npm/react-dom@18.3.1, npm/react@18.3.1, npm/scroll-into-view-if-needed@3.1.0, npm/throttle-debounce@5.0.0

View full report↗︎

@Ke1sy
Copy link
Contributor Author

Ke1sy commented May 24, 2024

@afc163 @zombieJ @MadCcc Please, review my PR. Thanks!

@yoyo837
Copy link
Contributor

yoyo837 commented May 24, 2024

In my personal opinion, this PR should be submitted to feature branch, but please mainly refer to @afc163 @zombieJ @MadCcc 's opinion.

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.

Table - Column filters are not keyboard operable/focusable
3 participants