-
Notifications
You must be signed in to change notification settings - Fork 94
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
refactor tooltip and popover components #747
Conversation
Deploy preview for pf-next ready! Built with commit c56a6b3 |
@@ -0,0 +1,6 @@ | |||
<div class="pf-c-popover__arrow{{#if popover-body--modifier}} {{popover-body--modifier}}{{/if}}" |
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.
these should be arrow not body for the modifier and attribute.
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.
doh! fixed.
{{#if popover-body--attribute}} | ||
{{{popover-body--attribute}}} | ||
{{/if}}> | ||
{{> @partial-block}} |
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.
Do we need to include {{> @partial-block}} here? I'm not sure. I was wondering this when I was looking at how we want to set our rules. It's not hurting anything, so I don't know if it matters. What do you think?
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.
I don't see the harm in adding the standard --modifier
, --attribute
and @partial-block
hbs code to all partials. I didn't have it initially, but it is more consistent to add it to any partial, and even though it doesn't do anything at the moment, it's there if we want to use it in the future. And doesn't add any bloat to PF itself, just a few lines of code to the workspace.
| `.pf-m-right` | `.pf-c-tooltip` | Puts arrow to the right of the tooltip's content. | | ||
| `.pf-m-top` | `.pf-c-tooltip` | Puts arrow on top of the tooltip's content. | | ||
| `.pf-m-bottom` | `.pf-c-tooltip` | Puts arrow on the bottom of the tooltip's content. | | ||
| `.pf-c-tooltip` | `<div>` | Creates a tooltip. Always use with a modifier class. | |
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.
Can you add required to this.
Really nice job! Just a few things I've noticed. |
I'm looking at the design and seeing that the tooltip is white. I wonder if we need to pull in design here and talk about the dark tooltips. Should there be a modifier for the dark/light tooltip/popover? |
|
||
## Accessibility | ||
|
||
| Attribute | Applied To | Outcome | | ||
| -- | -- | -- | | ||
| `aria-describedby="[id value of applicable content]"` | `.pf-c-tooltip` | Gives the tooltip an accessible description by referring to the tooltip content that describes the primary message or purpose of the dialog. Not used if there is no static text that describes the popover. | | ||
| `role="tooltip"` | `.pf-c-tooltip` | Adds a tooltip role to the tooltip component. **Required**| | ||
| `aria-describedby="[id of .pf-c-tooltip__content]"` | `*` | Gives the element that triggers the tooltip an accessible description by referring to the `id` of the `.pf-c-tooltip__content` element in the tooltip, describing the primary message or purpose of the element. Not used if there is no static text that describes the element. | |
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.
Using aria-describedby
matches the pattern described in the wai-aria example for tooltip, but there are two use cases that are described in the Inclusive Components article for tooltips:
- One where the tooltip provides a description using
aria-describedby
, which matches this example - One where the tooltip provides a label using
aria-labelledby
.
I'd like for us to be able to support both use cases. The second one will be a common use case wherever an icon is included without accompanying text.
What are your thoughts on updating this section to something like this?
Attribute | Applied To | Outcome |
---|---|---|
aria-describedby="[id of .pf-c-tooltip__content]" or aria-labelledby="[id of .pf-c-tooltip__content]" |
[element that triggers the tooltip] |
Makes the contents of the tooltip accessible to assistive technologies by associating the tooltip text with the element that triggers the tooltip. Use aria-labelledby if the tooltip provides a label for the element. Use aria-describedby if the element already has an accessible label and it's different from the tooltip text. |
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.
Oh, I forgot to include "Required" in my suggestion above. Either aria-labelledby
or aria-describedby
is required when using a tooltip to make the text accessible to screen readers.
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.
Yes looks great! Will update.
| `aria-describedby="[id value of applicable content]"` | `.pf-c-popover` | Gives the popover an accessible description by referring to the popover content that describes the primary message or purpose of the dialog. Not used if there is no static text that describes the popover. | | ||
| `aria-labelledby="[id of .pf-c-popover__header-title]"` | `.pf-c-button` | Gives the element that triggers the popover an accessible name by referring to popover's title. **Required when .pf-c-popover__header-title is present** | | ||
| `aria-label="[title of popover]"` | `.pf-c-button` | Gives the element that triggers the popover an accessible name. **Required when .pf-c-popover__header-title is _not_ present** | | ||
| `aria-describedby="[id of .pf-c-popover__body]"` | `.pf-c-button` | Gives the element that triggers popover an accessible description by referring to the popover's body text, describing the primary message or purpose of the dialog. Not used if there is no static text that describes the popover. | |
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.
I actually think that the previous descriptions for aria-label
, aria-labelledby
, and aria-describedby
were correct. I was thinking that a popover is very similar to a modal, and so a lot of the aria attributes we are using for the modal would apply to the popover, too. And the previous version of these attributes were a direct copy from the modal example.
Please me know if you found other examples that suggest a different method for handling popovers.
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.
Ah yes, I believe you're right. I was considering tooltips and popovers to be similar in terms of a11y, but a popover is basically a modal. And the changes I made are how Bootstrap handles their popovers (with the aria
attributes on the button that triggers it). I'll revert this section of the file.
| `aria-describedby="[id value of applicable content]"` | `.pf-c-popover` | Gives the popover an accessible description by referring to the popover content that describes the primary message or purpose of the dialog. Not used if there is no static text that describes the popover. | | ||
| `aria-labelledby="[id of .pf-c-popover__header-title]"` | `.pf-c-button` | Gives the element that triggers the popover an accessible name by referring to popover's title. **Required when .pf-c-popover__header-title is present** | | ||
| `aria-label="[title of popover]"` | `.pf-c-button` | Gives the element that triggers the popover an accessible name. **Required when .pf-c-popover__header-title is _not_ present** | | ||
| `aria-describedby="[id of .pf-c-popover__body]"` | `.pf-c-button` | Gives the element that triggers popover an accessible description by referring to the popover's body text, describing the primary message or purpose of the dialog. Not used if there is no static text that describes the popover. | | ||
| `aria-popover="true"` | `.pf-c-popover` | Tells assistive technologies that the windows underneath the current popover are not available for interaction. **Required**| |
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.
As I mentioned in my previous comment, this section was a copy/paste from the modal, and I think this was a find/replace mistake. There is no aria-popover
attribute, but there is an aria-modal
attribute.
@mcarrano Would you consider a popover to be a modal element? Is your expectation that popovers automatically disappear if the user clicks on elements outside the popover?
| `.pf-c-popover__header` | `.pf-c-popover__content` | The header text area of the popover. | | ||
| `.pf-c-popover__title` | `.pf-c-popover__header` | The actual popover title. | | ||
| `.pf-c-popover__body` | `.pf-c-popover__content` | The popover's body text. ** Required.** | | ||
| `.pf-c-popover` | `<div>` | Creates a popover. Always use it with a modifier class. **Required** | |
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.
Do you think consumers will understand that "Always use it with a modifier class" means to use a class like .pf-m-left
? I wonder if just updating the description for the modifier classes to something like "A modifier class that puts the arrow to the left of the popover's content" would help connect those dots.
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.
I'll add that, I don't think it will hurt and will add more context. Just so I'm sure what you're suggesting, instead of saying "Always use it with a modifier class", you're suggesting something like "Always use it with a modifier class that positions the popover relative to the element that triggered it."
Glad you mentioned this because currently these modifier descriptions are wrong (for example, pf-m-left
positions the popover to the left of the element that triggered it, so the arrow is actually on the right), and I don't think we should describe what the modifier does by where the arrow is, and instead describe it as a class that positions the popover. I made that change in the tooltip component and forgot to make it here.
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.
Oh and I meant to mention that the "always use with a modifier class" is something existing that we use on title, alert, button, and badge, too. Do you think it needs to be updated in those components as well?
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.
I was thinking that we would call out the classes that were modifier classes. So anytime we use a modifier class, we start the description by saying "A modifier class that...".
Class | Applied To | Outcome |
---|---|---|
.pf-m-left | .pf-c-popover | A modifier class that positions the popover to the left of the popover trigger |
But now that you described what you were thinking, I think either could work.
As for making this change in other component examples, I like having consistency. Do you want to update this example and see what everyone thinks?
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.
Ah, I see. Personally I think it's fine to not start modifier classes with "A modifier class that...", which assumes that folks understand that .pf-m-
denotes a class that modifies something in the component. I think it might be repetitive to have each modifier class start with that, too. Personally I think "always use with a modifier class" is explanatory enough, too - it means always use one of the .pf-m-
classes in the component... but I could be making assumptions, and having the additional descriptions could be helpful :) Agreed about consistency.
@michael-coker Your updates are great! I made a few comments about the documentation. Please let me know if you have any questions about them. |
@jgiardino thank you so much for the review!! appreciate you setting me straight on the a11y stuff :) Updated the PR with those changes if you want to have another look. |
👍 Looks good to me. I like your updates to the Usage section better than my suggestion. I agree that my suggestion would get redundant. Being someone who's usually clueless, I'm inclined to over-document. 😆 |
@jgiardino thanks!! would you mind marking the PR as reviewed/approved? |
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.
LGTM!
@michael-coker great Job, just one thing: The popover doesn't work well on dark environments. I don't know what the design ask for, do they want it to change to dark bg and white fonts, like the card, or they want it to stay white bg with dark fotns. We need to define this with @mceledonia or @kybaker and code it. |
@andresgalante sorry, I should have included this in the issue. Matt mentioned this, too, so I asked @kylebaker and here was his response.
|
{{#> popover popover--modifier="pf-m-bottom"}} | ||
{{#> popover-content}} | ||
{{#> popover-header}} | ||
{{#> popover-header-title popover-header-title--attribute='id="popover-bottom-header"'}} |
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.
delete space after title
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.
nice!
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.
LGTM! Just one little nit pick on whitspace :)
… to match AAA a11y
…escription of popover modifier classes, add aria-labelledby to tooltip a11y docs, be more descriptive with "always use with modifier class" in tooltip and popover docs, move role and aria-modal attrs from popover-content to the popover component
Filed #772 and added to the next alpha to revisit this issue separate from this PR. |
🎉 This PR is included in version 1.0.49 🎉 The release is available on: Your semantic-release bot 📦🚀 |
fixes #688
Not going to address the demo/functionality with this PR. We will demo that when the React components are built and we can use them in a demo.