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

fix(link-with-icon): removed keyboard focus on disable #4082

Conversation

IgnacioBecerra
Copy link
Contributor

@IgnacioBecerra IgnacioBecerra commented Sep 29, 2020

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

  • Removed tabIndex from the Link element

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Sep 29, 2020

@ibmdotcom-bot
Copy link
Contributor

ibmdotcom-bot commented Sep 29, 2020

Copy link
Contributor

@asudoh asudoh left a 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!

@IgnacioBecerra
Copy link
Contributor Author

@asudoh You're right, Link does turn it into <p>, I hadn't noticed that. Removed tabIndex as it's not necessary.

@jeffchew
Copy link
Member

@IgnacioBecerra looks like you need to update the snapshot file to reflect the change. You can do this with yarn test:unit:updateSnapshot in the web components package or react package.

Copy link
Contributor

@asudoh asudoh left a 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}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
tabIndex={disabled ? -1 : 0}

@@ -21,6 +21,7 @@ const { prefix } = settings;
const LinkWithIcon = ({
children,
className: customClassName,
disabled,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
disabled,

Comment on lines 59 to 63
/**
* Toggles keyboard tab focus for element
*/
disabled: PropTypes.bool,

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/**
* Toggles keyboard tab focus for element
*/
disabled: PropTypes.bool,

@@ -78,6 +84,7 @@ LinkWithIcon.propTypes = {

LinkWithIcon.defaultProps = {
children: [],
disabled: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
disabled: false,

@IgnacioBecerra
Copy link
Contributor Author

@asudoh Oh, my bad! I forgot to push the changes after writing that comment. No worries, you were clear enough 👍

Also, I updated the React screenshots, thanks @jeffchew!

@jeffchew
Copy link
Member

jeffchew commented Oct 1, 2020

@asudoh Oh, my bad! I forgot to push the changes after writing that comment. No worries, you were clear enough 👍

Also, I updated the React screenshots, thanks @jeffchew!

No worries! It looks like you have merge conflicts now, can you resolve?

Copy link
Contributor

@asudoh asudoh left a 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!

@IgnacioBecerra IgnacioBecerra force-pushed the link-with-icon-tab-disable branch from 4427efe to 8eea69b Compare October 1, 2020 17:27
@IgnacioBecerra IgnacioBecerra reopened this Oct 1, 2020
@jeffchew
Copy link
Member

jeffchew commented Oct 1, 2020

@IgnacioBecerra you may need to re-run the updateSnapshot task to fix this.

@jeffchew jeffchew added the Ready to merge Label for the pull requests that are ready to merge label Oct 1, 2020
@kodiakhq kodiakhq bot merged commit 4d8ecb7 into carbon-design-system:master Oct 1, 2020
ariellalgilmore pushed a commit to ariellalgilmore/carbon-for-ibm-dotcom that referenced this pull request Oct 2, 2020
…-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) -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge Label for the pull requests that are ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants