-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
NavigableContainer
: convert to TypeScript
#49377
Conversation
Size Change: +41 B (0%) Total Size: 1.37 MB
ℹ️ View Unchanged
|
packages/components/src/navigable-container/stories/navigable-menu.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/navigable-container/test/navigable-menu.tsx
Outdated
Show resolved
Hide resolved
Flaky tests detected in eb8b909. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/4710317571
|
packages/components/src/navigable-container/test/tababble-container.tsx
Outdated
Show resolved
Hide resolved
Hi @ciampo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work so far! This PR is already in quite a good spot :)
I've focused on reading the code so far — in the next rounds I'll take a closer look and run the code too.
const { onlyBrowserTabstops } = this.props; | ||
const finder = onlyBrowserTabstops ? focus.tabbable : focus.focusable; | ||
const focusables = finder.find( this.container ); | ||
const focusables = finder.find( this.container ) as HTMLElement[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
finder.find
returns an Element[]
. Not something for this PR, but it would be interesting to understand if the return type could be safely narrowed to HTMLElement[]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
packages/components/src/navigable-container/stories/navigable-menu.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/navigable-container/test/tababble-container.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/navigable-container/test/tababble-container.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/navigable-container/test/navigable-menu.tsx
Outdated
Show resolved
Hide resolved
@ciampo, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to tweak the Storybook settings:
- probably disable
children
controls - remove other unnecessary controls, since the same info can be inferred from the TypeScript types
- add
parameters
to enable controls and docs
Proposed diff
diff --git a/packages/components/src/navigable-container/stories/navigable-menu.tsx b/packages/components/src/navigable-container/stories/navigable-menu.tsx
index 0c433e01fd..5f8ee2e4e5 100644
--- a/packages/components/src/navigable-container/stories/navigable-menu.tsx
+++ b/packages/components/src/navigable-container/stories/navigable-menu.tsx
@@ -13,11 +13,13 @@ const meta: ComponentMeta< typeof NavigableMenu > = {
component: NavigableMenu,
argTypes: {
children: { control: { type: null } },
- onNavigate: { action: 'onNavigate' },
- orientation: {
- options: [ 'horizontal', 'vertical' ],
- control: { type: 'radio' },
+ },
+ parameters: {
+ actions: { argTypesRegex: '^on.*' },
+ controls: {
+ expanded: true,
},
+ docs: { source: { state: 'open' } },
},
};
export default meta;
diff --git a/packages/components/src/navigable-container/stories/tabbable-container.tsx b/packages/components/src/navigable-container/stories/tabbable-container.tsx
index 8b9221ea54..b517019e29 100644
--- a/packages/components/src/navigable-container/stories/tabbable-container.tsx
+++ b/packages/components/src/navigable-container/stories/tabbable-container.tsx
@@ -12,11 +12,14 @@ const meta: ComponentMeta< typeof TabbableContainer > = {
title: 'Components/TabbableContainer',
component: TabbableContainer,
argTypes: {
- children: { type: undefined },
- cycle: {
- type: 'boolean',
+ children: { control: { type: null } },
+ },
+ parameters: {
+ actions: { argTypesRegex: '^on.*' },
+ controls: {
+ expanded: true,
},
- onNavigate: { action: 'onNavigate' },
+ docs: { source: { state: 'open' } },
},
};
export default meta;
…ontainer/container.tsx Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
…ontainer/stories/navigable-menu.tsx Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
…ontainer/container.tsx Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
…ontainer/container.tsx Co-authored-by: Marco Ciampini <marco.ciampo@gmail.com>
7dc3c71
to
a8b6bf5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (sorry for the delay!) 🚀
(and thank you once more for your collaboration @kienstra , we really appreciate it 🙏 )
cc @chad1008 |
Oh all good! Thanks for your great reviews as always! |
What?
Convert
NavigableContainer
components to TypeSccriptWhy?
As part of #35744
How?
Mainly by adding types
Testing Instructions
npm run storybook:dev
NavigableMenu
andTabbableContainer
Testing Instructions for Keyboard
npm run storybook:dev
NavigableMenu
andTabbableContainer
Screenshots or screencast
See above