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

feat(thumbnail-card): remove role and tabIndex when onKeyDown exists #3898

Conversation

jmcbgaston
Copy link
Contributor

  • add condition for role and tabIndex
  • update specs

@jmcbgaston jmcbgaston requested a review from a team as a code owner February 6, 2025 00:35
@jmcbgaston jmcbgaston self-assigned this Feb 6, 2025
className={classNames('thumbnail-card', className, { 'is-highlight-applied': highlightOnHover })}
role={onKeyDown ? null : 'button'}
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to see the role and tabIndex prop to null or undefined? Setting undefined makes it as if the role and tabIndex were not passed anything while null is passing a null object.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like react will strip this sort of thing (falsey values) out of the dom
sandbox: https://codesandbox.io/p/sandbox/lr8dj4

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

fyi that link refers to when HTML nodes are falsey values whereas Jackie's question refers to attributes of an element. for example, you can set data- attributes to false and you'll still see those values in the DOM

it looks like there's some logic that determines what type of attributes should be hidden when falsey: https://stackoverflow.com/a/31164090

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right, but confirmed that attributes are also stripped in the sandbox

className={classNames('thumbnail-card', className, { 'is-highlight-applied': highlightOnHover })}
role={onKeyDown ? null : 'button'}
Copy link
Contributor

Choose a reason for hiding this comment

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

fyi that link refers to when HTML nodes are falsey values whereas Jackie's question refers to attributes of an element. for example, you can set data- attributes to false and you'll still see those values in the DOM

it looks like there's some logic that determines what type of attributes should be hidden when falsey: https://stackoverflow.com/a/31164090

@mergify mergify bot merged commit 322231b into box:master Feb 11, 2025
6 checks passed
@jmcbgaston jmcbgaston deleted the update-thumbnail-card-remove-role-and-tabIndex-when-onKeyDown branch February 11, 2025 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants