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

refactor(ui-dom-utils): update findFocusable logic #1223

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/ui-dom-utils/src/__tests__/findTabbable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ describe('findTabbable', async () => {
<button>Yep</button>
<button style={{ display: 'none' }}>Nope</button>
</div>
<div style={{ width: 0, height: 0 }}>
<button>Nope</button>
</div>
</div>
)
/* eslint-enable jsx-a11y/no-noninteractive-tabindex */
Expand Down
7 changes: 1 addition & 6 deletions packages/ui-dom-utils/src/findFocusable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,7 @@ function findFocusable(

function hidden(element: Element | Node) {
const cs = getComputedStyle(element)
return (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This refers to a ticket on the Slack channel. After researching the issue, I discovered that the developers who were implementing the feature had left. Therefore, I decided to remove the feature and test how it affected the components. Overall, everything was fine in the manual test. I suggest writing unit tests.

(cs.display !== 'inline' &&
(element as HTMLElement).offsetWidth <= 0 &&
(element as HTMLElement).offsetHeight <= 0) ||
cs.display === 'none'
)
return cs.display === 'none'
}

function positioned(element: Element | Node) {
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,7 @@ __metadata:
languageName: node
linkType: hard

"@babel/runtime@npm:^7.22.6":
"@babel/runtime@npm:^7.22.5, @babel/runtime@npm:^7.22.6":
version: 7.22.6
resolution: "@babel/runtime@npm:7.22.6"
dependencies:
Expand Down
Loading