Skip to content

Add Support for disabled state tabs#6261

Merged
nicolethoen merged 7 commits intopatternfly:mainfrom
CooperRedhat:tabs-disables
Sep 13, 2021
Merged

Add Support for disabled state tabs#6261
nicolethoen merged 7 commits intopatternfly:mainfrom
CooperRedhat:tabs-disables

Conversation

@CooperRedhat
Copy link
Contributor

@CooperRedhat CooperRedhat commented Sep 2, 2021

What: Closes #6162

Additional issues:

  • Refactored Tab into it's own component in order to forwardRef for Tooltip in aria-disabled case re: Original Request
  • Added disabled state examples to match core PR for same issue

@patternfly-build
Copy link
Collaborator

patternfly-build commented Sep 2, 2021

PF4 preview: https://patternfly-react-pr-6261.surge.sh

mcarrano
mcarrano previously approved these changes Sep 9, 2021
Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thanks @CooperRedhat !

Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

LGTM After a11y tests pass

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

Looks good! Can you also add an example of when a tab button is an <a> (in the nav and subnav element examples - https://patternfly-react-pr-6261.surge.sh/components/tabs#using-the-nav-element)? Here are the core examples - https://pf4.patternfly.org/components/tabs#using-the-nav-element

@CooperRedhat
Copy link
Contributor Author

Note: Nav examples with anchor tags/hrefs were not updating active state, added preventDefault to click handler (which is what jumplinks do), should be working now.

Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

Just one change - with a disabled nav tab/link:

  • Replace the disabled attribute with aria-disabled="true" (disabled isn't valid on an <a>)
  • Add tabindex="-1" to remove it from the tab order

Copy link
Contributor

@kmcfaul kmcfaul left a comment

Choose a reason for hiding this comment

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

Looks like the examples have some duplicate ids that are causing a11y tests to fail.

</li>
);
})}
{filteredChildren}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little confused why this mapping is no longer needed, did the structure of filteredChildren change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tab component used to return null, i.e. render nothing. So filtered children was just an array of objects. I needed a ref on the tab component for tooltips, so I had to forward ref and render an instance to attach a ref to.

@CooperRedhat
Copy link
Contributor Author

Looks like the examples have some duplicate ids that are causing a11y tests to fail.

Looks like the duplicate IDs came from wrapping a tab in a tooltip, we'll see if it passes.

@CooperRedhat CooperRedhat requested a review from mcoker September 10, 2021 17:53
nicolethoen
nicolethoen previously approved these changes Sep 10, 2021
Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

Screen Shot 2021-09-10 at 1 52 42 PM

For regular disabled nav links:

  • Remove disabled
    • An <a> doesn't support the disabled attr.
  • Add aria-disabled="true"
    • Since the browser doesn't disable a link for you, you have to tell screen readers its disabled
  • Add tabindex="-1"
    • Since its disabled, you don't want users to be able to tab to it (just like tab buttons that are disabled)

Screen Shot 2021-09-10 at 1 53 12 PM

For aria-disabled tab links:

  • Add aria-disabled="true"
    • Same as above
  • Remove the tabindex attr
    • You want users to be able to tab to it to trigger the popover/tooltip

@tlabaj tlabaj added the A11y label Sep 10, 2021
Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

Can you had a demo and some integration test to verify the disables tabs?

Copy link
Contributor

@jessiehuff jessiehuff left a comment

Choose a reason for hiding this comment

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

So in this scenario, I don't think we actually want to add a tabIndex="-1" to the tab because it will make the tooltip completely inaccessible by keyboard. The weird thing about aria-disabled elements is they're kind of like a combination of disabled and interactive elements. Adding a tooltip makes it kind of interactive, but the main action of the tab is disabled. However, by playing with the preview, even when I take the tabIndex off the tooltip isn't displaying on focus so I'm not positive what's going on there. I also noticed that the tooltip isn't getting announced in VO. I think we need an aria-describedby="whatever the tooltip's id is". A good example to follow is our aria-disabled button with tooltip examples.

mcoker
mcoker previously approved these changes Sep 10, 2021
Copy link
Contributor

@mcoker mcoker left a comment

Choose a reason for hiding this comment

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

LGTM!

@nicolethoen nicolethoen merged commit 799b9c3 into patternfly:main Sep 13, 2021
Copy link
Contributor

@jessiehuff jessiehuff left a comment

Choose a reason for hiding this comment

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

So I noticed in reviewing that the tooltip still isn't showing up on keyboard focus. I asked Nicole if she could test that aspect too, and she noticed that if you pressed enter the tooltip will appear. That's pretty unexpected that it would appear on hover for mouse users but require interaction to appear for keyboard users. However, we also noticed that this happened with the tooltip on enabled tabs as well. Nicole came up with a good theory that it may have to do with a discrepancy between where the tooltip is put (on the li) and where the focus is (on a button). We could probably create a follow up issue to investigate.

Also, I think we only need the tabIndex="0" if there's something interactive on the disabled tab. We should probably create an issue to add this to our documentation as well.

Update: I created the issues for us. :)

@patternfly-build
Copy link
Collaborator

Your changes have been released in:

  • @patternfly/react-catalog-view-extension@4.12.69
  • @patternfly/react-code-editor@4.3.56
  • @patternfly/react-console@4.11.37
  • @patternfly/react-core@4.156.3
  • @patternfly/react-docs@5.21.35
  • @patternfly/react-inline-edit-extension@4.7.79
  • demo-app-ts@4.120.6
  • @patternfly/react-integration@4.121.2
  • @patternfly/react-log-viewer@4.6.9
  • @patternfly/react-table@4.29.72
  • @patternfly/react-topology@4.9.75
  • @patternfly/react-virtualized-extension@4.9.44

Thanks for your contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add disabled state for Tabs

8 participants