Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

fix(Tooltop): a11y improvements #2245

Merged
merged 18 commits into from
Apr 25, 2019

Conversation

paschalidi
Copy link
Contributor

@paschalidi paschalidi commented Apr 19, 2019

🌳 👋 hello to you all 🌻 Hope you enjoying the great day!

Continues on https://github.com/IBM/carbon-components-react/issues/2193

Tackles the following

  • removes IconTitle - its not needed for a11y.
  • removes aria-owns - this attribute its not needed for a11y in the tooltip according to https://github.com/IBM/carbon-components-react/issues/2193
  • removes aria-labelledby this attribute its not needed for a11y in the tooltip according to https://github.com/IBM/carbon-components-react/issues/2193
  • when Icon is present then the div wrapping the Icon has all the attributes are are relevant to the action of showing the Tooltip. When the Icon component is not present those attributes are now being parsed to the div that wraps the actual text. I call these attributes properties its not a very distinct name please feel free to suggest something more meaningful!
  • when triggerText is not being parsed user gets error message that the property iconDescription is required in order to have better user experience

Changelog

Tooltip a11y changes.

##Future 👨‍🚀
The next PR would be regarding

try to use a button element instead of div role="button" tabindex="0" ... and use onclick instead of handling space and enter keys

from https://github.com/IBM/carbon-components-react/issues/2193

@netlify
Copy link

netlify bot commented Apr 19, 2019

Deploy preview for carbon-components-react ready!

Built with commit de2fc39

https://deploy-preview-2245--carbon-components-react.netlify.com

@netlify
Copy link

netlify bot commented Apr 19, 2019

Deploy preview for carbon-components-react ready!

Built with commit f359e1f

https://deploy-preview-2245--carbon-components-react.netlify.com

Copy link
Contributor

@dakahn dakahn left a comment

Choose a reason for hiding this comment

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

Hey, first of all thank you so much for jumping in on this work. 🙏

There's a bug where on FF on Windows 10 you can't open a Tooltip with a mouseclick. You can however open it with a keyboard, but it's way off to the left.

2019-04-19 18_32_49-Carbon Components React

@paschalidi
Copy link
Contributor Author

@dakahn i can reproduce it. will take care of it as soon as possible. Thanks for taking care of this

@paschalidi
Copy link
Contributor Author

paschalidi commented Apr 20, 2019

@dakahn hey thanks for reviewing! In my FF the bug is now fixed. Problem was that I created that FinalIcon functional component and refs cannot be passed into functional components just classes therefore clicking in the icon itself would feel like clicking also outside of the tooltip therefore would trigger it to close it..

Well hope that makes little bit of sense.
Have another look when your time allows it!

* The title of the default tooltip icon, to be put in its SVG `<title>` element.
*/
iconTitle: PropTypes.string,
iconDescription: ({ triggerText, iconDescription }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

{finalIcon}
<div className={`${prefix}--tooltip__trigger`} {...properties}>
{IconCustomElement ? (
<IconCustomElement {...iconProperties} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to set triggerEl for <IconCustomElement> in addition to <Icon>.

onMouseOut: this.handleMouse,
onFocus: this.handleMouse,
onBlur: this.handleMouse,
ref: mergeRefs(ref, node => {
Copy link
Contributor

Choose a reason for hiding this comment

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

This ref should be set to <div className={triggerClasses}> only when its content is text-only. This is for locating tooltip relative to icon when it's present, and to the containing <div> otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for explaining, was not very clear to me .. will fix that

@paschalidi
Copy link
Contributor Author

@asudoh maybe have another look

@asudoh
Copy link
Contributor

asudoh commented Apr 24, 2019

@paschalidi Have you had a chance to address my comments...? Thanks!

@paschalidi
Copy link
Contributor Author

I did but for some reason never pushed those changes. very sorry for notifying for no good reason @asudoh.

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.

LGTM 👍 - Thanks @paschalidi!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants