-
Notifications
You must be signed in to change notification settings - Fork 159
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(link-with-icon): removed keyboard focus on disable #4082
fix(link-with-icon): removed keyboard focus on disable #4082
Conversation
Deploy preview created for package Built with commit: 55503c762e3e26ead98c481f1098df507cdb61ae |
Deploy preview created for package Built with commit: 55503c762e3e26ead98c481f1098df507cdb61ae |
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.
Hi @IgnacioBecerra I think the internal <Link>
is keyboard-focusable even without tabIndex
specified given it uses <a>
internally. The internal <Link>
automatically turns off such focusability if it's disabled, by turning it to <p>
. That said, would you try simply removing tabIndex
from the internal <Link>
? Thanks!
@asudoh You're right, Link does turn it into |
@IgnacioBecerra looks like you need to update the snapshot file to reflect the change. You can do this with |
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.
Thank you for the update @IgnacioBecerra - Below is what I actually meant in case I wasn't clear enough (my apologies if it's the case). Please let me know if it doesn't work. Thanks!
@@ -37,7 +38,7 @@ const LinkWithIcon = ({ | |||
)} | |||
data-autoid={`${stablePrefix}--link-with-icon`}> | |||
<Link | |||
tabIndex={0} | |||
tabIndex={disabled ? -1 : 0} |
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.
tabIndex={disabled ? -1 : 0} |
@@ -21,6 +21,7 @@ const { prefix } = settings; | |||
const LinkWithIcon = ({ | |||
children, | |||
className: customClassName, | |||
disabled, |
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.
disabled, |
/** | ||
* Toggles keyboard tab focus for element | ||
*/ | ||
disabled: PropTypes.bool, | ||
|
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.
/** | |
* Toggles keyboard tab focus for element | |
*/ | |
disabled: PropTypes.bool, |
@@ -78,6 +84,7 @@ LinkWithIcon.propTypes = { | |||
|
|||
LinkWithIcon.defaultProps = { | |||
children: [], | |||
disabled: false, |
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.
disabled: false, |
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.
Cool, LGTM 👍 once the snapshot is recreated to resolve the merge conflict. Thanks a lot @IgnacioBecerra!
4427efe
to
8eea69b
Compare
@IgnacioBecerra you may need to re-run the updateSnapshot task to fix this. |
…-system#4082) ### Related Ticket(s) carbon-design-system#3712 ### Description The main issue that caused the element to still be focused even while disabled. Removed `tabIndex` as it should still respect the focus order while active and not focus during disabled state. ### Changelog **Removed** - Removed tabIndex from the `Link` element <!-- React and Web Component deploy previews are enabled by default. --> <!-- To enable additional available deploy previews, apply the following --> <!-- labels for the corresponding package: --> <!-- *** "package: vanilla": Vanilla --> <!-- *** "package: services": Services --> <!-- *** "package: utilities": Utilities --> <!-- *** "package: styles": Carbon Expressive, React (Expressive) --> <!-- *** "RTL": React (RTL) --> <!-- *** "feature flag": React (experimental) -->
Related Ticket(s)
#3712
Description
The main issue that caused the element to still be focused even while disabled. Removed
tabIndex
as it should still respect the focus order while active and not focus during disabled state.Changelog
Removed
Link
element