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

refactor tooltip and popover components #747

Merged
merged 13 commits into from
Sep 28, 2018

Conversation

mcoker
Copy link
Contributor

@mcoker mcoker commented Sep 20, 2018

fixes #688

  • refactored arrow positioning in both components
  • update minWidth/minHeight global vars for target size
  • updates to a11y and docs for both components
  • refactor handlebars code

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.

@patternfly-build
Copy link

patternfly-build commented Sep 20, 2018

Deploy preview for pf-next ready!

Built with commit c56a6b3

https://deploy-preview-747--pf-next.netlify.com

@@ -0,0 +1,6 @@
<div class="pf-c-popover__arrow{{#if popover-body--modifier}} {{popover-body--modifier}}{{/if}}"
Copy link
Contributor

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.

Copy link
Contributor Author

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}}
Copy link
Contributor

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?

Copy link
Contributor Author

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. |
Copy link
Contributor

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.

@matthewcarleton
Copy link
Contributor

Really nice job! Just a few things I've noticed.

@matthewcarleton
Copy link
Contributor

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. |
Copy link
Contributor

@jgiardino jgiardino Sep 25, 2018

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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. |
Copy link
Contributor

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.

Copy link
Contributor Author

@mcoker mcoker Sep 25, 2018

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**|
Copy link
Contributor

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** |
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@jgiardino
Copy link
Contributor

@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.

@mcoker
Copy link
Contributor Author

mcoker commented Sep 25, 2018

@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.

@jgiardino
Copy link
Contributor

👍 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. 😆

@mcoker
Copy link
Contributor Author

mcoker commented Sep 26, 2018

@jgiardino thanks!! would you mind marking the PR as reviewed/approved?

Copy link
Contributor

@jgiardino jgiardino left a comment

Choose a reason for hiding this comment

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

LGTM!

@andresgalante
Copy link
Member

@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.

@mcoker
Copy link
Contributor Author

mcoker commented Sep 28, 2018

@andresgalante sorry, I should have included this in the issue. Matt mentioned this, too, so I asked @kylebaker and here was his response.

@mcoker Follow the design suggested in issue 474 - the dark. 14px font and 16 px margin

{{#> popover popover--modifier="pf-m-bottom"}}
{{#> popover-content}}
{{#> popover-header}}
{{#> popover-header-title popover-header-title--attribute='id="popover-bottom-header"'}}
Copy link
Contributor

Choose a reason for hiding this comment

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

delete space after title

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nice!

Copy link
Contributor

@matthewcarleton matthewcarleton left a 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 :)

…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
@LHinson
Copy link
Member

LHinson commented Sep 28, 2018

@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.

Filed #772 and added to the next alpha to revisit this issue separate from this PR.

@patternfly-build
Copy link

🎉 This PR is included in version 1.0.49 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

None yet

6 participants