Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PR: menu → focus-group refactoring #16

Merged
merged 16 commits into from
Mar 14, 2024

Conversation

dmitry-kurmanov
Copy link
Contributor

@dmitry-kurmanov dmitry-kurmanov commented Mar 6, 2024

without toolbox
see #9

focus-group.js Outdated
}

return false
}
Copy link
Owner

Choose a reason for hiding this comment

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

Newline at the end of the file is missed.

I can recommend installing EditorConfig extension to your text editor.

focus-group.js Outdated
@@ -109,3 +107,36 @@ export function menuKeyUX(options) {
}
}
}

export function findGroupNodeByEventTarget(eventTarget) {
Copy link
Owner

Choose a reason for hiding this comment

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

Do we need to export them?

Removing export will reduce JS bundle size

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 use export for testing purposes only, probably there is a better way to test the method...

Copy link
Owner

Choose a reason for hiding this comment

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

Can we do integration testing instead (test the whole feature)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure I just don't know which strategy is better here... I will try to fix it today evening!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

focus-group.js Outdated
@@ -109,3 +107,36 @@ export function menuKeyUX(options) {
}
}
}

export function findGroupNodeByEventTarget(eventTarget) {
let supportedRoles = {
Copy link
Owner

Choose a reason for hiding this comment

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

We need to move it out of the function to const

focus-group.js Outdated
@@ -109,3 +107,36 @@ export function menuKeyUX(options) {
}
}
}

Copy link
Owner

Choose a reason for hiding this comment

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

Can you move those helpers above the place where we are using them?

focus-group.js Outdated
if (ariaOrientation === "vertical") return false
if (ariaOrientation === "horizontal") return true

if (!ariaOrientation) {
Copy link
Owner

Choose a reason for hiding this comment

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

Why we need this if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

according to the doc the aria-orientation has 3 possible values:

image

Those if statement needs to handle the undefined or default value. If I understand it correctly in case of menubar or tablist it should be horizontal unless explicitly set

focus-group.js Outdated
if (!groupRoles) return null

let result
groupRoles.forEach((role) => {
Copy link
Owner

Choose a reason for hiding this comment

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

It is better to use for of here and return on found. Because otherwise you will do unnecessary search for menubar if menu was already found.

index.d.ts Outdated
@@ -28,7 +28,7 @@ export interface KeyUXModule {
(window: MinimalWindow): () => void
}

export interface MenuKeyUXOptions {
export interface focusGroupKeyUXOptions {
Copy link
Owner

Choose a reason for hiding this comment

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

FocusGroupKeyUXOptions

@dmitry-kurmanov dmitry-kurmanov requested a review from ai March 10, 2024 15:23
focus-group.js Outdated
if (ariaOrientation === "vertical") return false
if (ariaOrientation === "horizontal") return true

if (!ariaOrientation) {
Copy link
Owner

Choose a reason for hiding this comment

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

What case will we miss if we will write:

-   if (!ariaOrientation) {
-       let role = group.role
-       return role === "menubar" || role === "tablist"
-     }
-     return false
+ let role = group.role
+ return role === "menubar" || role === "tablist"

focus-group.js Outdated
@@ -1,6 +1,12 @@
export function menuKeyUX(options) {
const Roles = {
Copy link
Owner

Choose a reason for hiding this comment

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

In my code style I use ROLES. Can you replace, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! My bad I missed it

@ai
Copy link
Owner

ai commented Mar 13, 2024

Fix ESLint rules and that small notes and I think we could move PR from draft to ready state.

@dmitry-kurmanov dmitry-kurmanov marked this pull request as ready for review March 14, 2024 06:03
@ai ai merged commit b873f8b into ai:main Mar 14, 2024
4 checks passed
@ai
Copy link
Owner

ai commented Mar 14, 2024

Also, note the a little more proper way to make tab’s body

keyux/test/demo/index.tsx

Lines 308 to 313 in 294ef40

<div
className="tabs_body"
hidden={tab !== 'home'}
id="tab_home"
role="tabpanel"
>

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants