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

feat(SimpleList): add simple list #3645

Merged
merged 12 commits into from Feb 14, 2020
Merged

Conversation

kmcfaul
Copy link
Contributor

@kmcfaul kmcfaul commented Feb 3, 2020

What: Closes #3610

@mcoker It appears that pf-c-simple-list__list and pf-c-simple-list__list-item do not exist/are not in use despite appearing on the HTML structure in core. Let me know if I should add them manually, but currently I have left them off.

@kmcfaul kmcfaul added css review PF4 React issues for the PF4 core effort ux review labels Feb 3, 2020
@patternfly-build
Copy link
Contributor

patternfly-build commented Feb 3, 2020

@mcoker
Copy link
Contributor

mcoker commented Feb 3, 2020

  • I wonder if we should add an id to the __title, then aria-labelledby to the __section to match the nav component? Also curious if we should make that update to the dropdown, app launcher, options menu, etc?
  • We probably want to add type="button" to the buttons so that they aren't submit buttons.
  • This is a bug in core, but we need to add text-decoration: none to the <a> items so that they don't get an underline on hover.
  • Add an href attribute to the <a> __item-link elements so that they're in the tabindex. Or maybe add tabindex="0" to elements that aren't a button, or just all for consistency?

cc @jessiehuff

It appears that pf-c-simple-list__list and pf-c-simple-list__list-item do not exist/are not in use despite appearing on the HTML structure in core. Let me know if I should add them manually, but currently I have left them off.

I'm curious what @tlabaj thinks about this. I'm not sure that we have a consistent way of doing this, and it often comes up in the PR when we give an element a class that doesn't have a corresponding style.

The main reason we do it is that it helps build the BEM structure (creates a namespace for elements), and allows us to style those elements at some later point without requiring users update their markup to add a new class. That mostly applies to core users, since we can always add a missing class to a react component after the fact.

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.

This looks good to me. @lboehling acn you also take a look?

@kmcfaul
Copy link
Contributor Author

kmcfaul commented Feb 4, 2020

@mcoker Added your bullets (minus the core one). I went with adding the tabindex="0" only to the anchor elements.

@jessiehuff Let me know if I'm missing any other aria labels or tags that should be explicitly defined. I think in most cases using the ...props to pass these in should work.

@codecov-io
Copy link

codecov-io commented Feb 4, 2020

Codecov Report

Merging #3645 into master will increase coverage by 0.07%.
The diff coverage is 91.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3645      +/-   ##
==========================================
+ Coverage   71.22%   71.29%   +0.07%     
==========================================
  Files         779      782       +3     
  Lines       10491    10528      +37     
  Branches     2263     2277      +14     
==========================================
+ Hits         7472     7506      +34     
- Misses       2592     2594       +2     
- Partials      427      428       +1
Flag Coverage Δ
#misc 95.45% <ø> (ø) ⬆️
#patternfly3 85.89% <ø> (ø) ⬆️
#patternfly4 60.32% <91.89%> (+0.19%) ⬆️
Impacted Files Coverage Δ
...-core/src/components/SimpleList/SimpleListItem.tsx 100% <100%> (ø)
...core/src/components/SimpleList/SimpleListGroup.tsx 71.42% <71.42%> (ø)
...eact-core/src/components/SimpleList/SimpleList.tsx 94.73% <94.73%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eab8040...c0174ee. Read the comment docs.

mcoker
mcoker previously approved these changes Feb 4, 2020
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, thanks!!

/** Additional classes added to the SimpleList <ul> */
className?: string;
/** Callback when an item is selected */
onSelect?: (ref: React.RefObject<HTMLButtonElement> | React.RefObject<HTMLAnchorElement>) => void;
Copy link
Member

Choose a reason for hiding this comment

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

Instead of providing the button associated with clicking on each menu option, I'd prefer to provide my own ID. I can get the label from the button, but it's difficult to work with considering the label may be localized.

Screen Shot 2020-02-05 at 10 59 26 AM
...
Screen Shot 2020-02-05 at 10 59 46 AM

@dlabaj I believe we may be using SelectOption to help with this?

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.

@kmcfaul some of the list items seem to be showing an underline on_hover. See below. Why is that?

Screen Shot 2020-02-05 at 1 43 42 PM

@mcoker
Copy link
Contributor

mcoker commented Feb 5, 2020

@mcarrano that's a bug from core. Just put up a PR to fix patternfly/patternfly#2679****

@mcoker
Copy link
Contributor

mcoker commented Feb 8, 2020

@kmcfaul the underline is fixed patternfly/patternfly#2679 (v2.59.1)

@kmcfaul
Copy link
Contributor Author

kmcfaul commented Feb 10, 2020

@dlabrecq
I added another property to the callback function that will pass back the item's props. This will work for id and the like without any special declaration.

However, I could instead add another property to SimpleListItem that would be used to pass back data, instead of props. It would be clearer what gets passed back using this approach but would require extra user input to define the structure.

Any thoughts about which approach would be better?

dlabrecq
dlabrecq previously approved these changes Feb 12, 2020
Copy link
Member

@dlabrecq dlabrecq left a comment

Choose a reason for hiding this comment

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

Thanks for adding SimpleListItemProps

import { css } from '@patternfly/react-styles';
import styles from '@patternfly/react-styles/css/components/SimpleList/simple-list';

export interface SimpleListGroupProps {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should extend HTMLProps for section

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 could only find React.HTMLProps<HTMLTableSectionElement>, would this be correct? It seems to work with the console logging warnings

Copy link
Collaborator

Choose a reason for hiding this comment

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

hm, how about passing <any> in this case since we just want the default HTML attributes


const componentProps = isButton
? {
type
Copy link
Collaborator

Choose a reason for hiding this comment

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

just making sure this is intended, but type can be submit or reset as well if that's what's passed in as prop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we want to make sure the default type is "button", this line lets the user change that if they wish. otherwise adding a type property manually would be caught by the component and not actually set.

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'm not sure either way if we want to allow this

@mcarrano

return (
<li className={css(listItemClassName)}>
<Component
className={css(styles.simpleListItemLink, isCurrentItem && styles.modifiers.current, className)}
Copy link
Collaborator

Choose a reason for hiding this comment

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

className should be on the root element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved these (className, props) to root element and added properties to customize the inner component.

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.

From an accessibility standpoint, it looks pretty good. Similar to what Coker was saying earlier, it would be beneficial to add an aria-labelledby. However, based on current recommendations, it looks like it should be added to the <ul>s though, for example here:
image (5)
This aids the screen reader by being more descriptive about what that list is describing. In VO it will read "list, Group 1, 4 items" instead of "list 4 items" and not telling you which group you're under.

In terms of this pattern in other components like dropdown, app launcher, options menu, etc, I think more research and discussion would be beneficial. It can be a fine line between being descriptive and overusing aria which makes those decisions more challenging.

Great job, Katie! :)

jschuler
jschuler previously approved these changes Feb 13, 2020
jessiehuff
jessiehuff previously approved these changes Feb 13, 2020
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.

LGTM! :)

dlabrecq
dlabrecq previously approved these changes Feb 13, 2020
Copy link
Contributor

@mattnolting mattnolting left a comment

Choose a reason for hiding this comment

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

As a followup to @jessiehuff's and @mcoker's comments and based on my VO testing, there are a couple of things you can improve here and that we need to improve upstream.

  • Add aria-labe="Grouped list example"l to parent list
  • Add role="list" to parent list .pf-c-simple-list
  • Add aria-hidden="true" to titles

Adding these attributes will announce that the parent .pf-c-simple-list is a list, how many sub-lists it contains and will remove titles from tabindex as they are announced when list is focused.

<div class="pf-c-simple-list" role="list" aria-label="Grouped list example">
  <section class="pf-c-simple-list__section">
    <h2 id="group-title-1" class="pf-c-simple-list__title" aria-hidden="true">Systems that are neat</h2>
    <ul class="" aria-labelledby="group-title-1">
      <li class="pf-c-simple-list__item">
        <button class="pf-c-simple-list__item-link pf-m-current" type="button">List item 1</button>
      </li>
      <li class="pf-c-simple-list__item">
        <button class="pf-c-simple-list__item-link" type="button">List item 2</button>
      </li>
      <li class="pf-c-simple-list__item">
        <button class="pf-c-simple-list__item-link" type="button">List item 3</button>
      </li>
      <li class="pf-c-simple-list__item">
        <button class="pf-c-simple-list__item-link" type="button">List item 4</button>
      </li>
    </ul>
  </section>
  <section class="pf-c-simple-list__section">
    <h2 id="group-title-1 " class="pf-c-simple-list__title" aria-hidden="true">Group 2</h2>
    <ul class="" aria-labelledby="group-2">
      <li class="pf-c-simple-list__item">
        <button class="pf-c-simple-list__item-link" type="button">List item 1</button>
      </li>
      <li class="pf-c-simple-list__item">
        <a class="pf-c-simple-list__item-link" href="#">List item 2</a>
      </li>
      <li class="pf-c-simple-list__item">
        <a class="pf-c-simple-list__item-link" href="#">List item 3</a>
      </li>
      <li class="pf-c-simple-list__item">
        <button class="pf-c-simple-list__item-link" type="button">List item 4</button>
      </li>
    </ul>
  </section>
</div>

@mattnolting
Copy link
Contributor

I would also really like to see the component selectors manually added to the <li>s, but that's a larger discussion and not a blocker 😄

@kmcfaul kmcfaul dismissed stale reviews from dlabrecq, jessiehuff, and jschuler via 6ee92df February 13, 2020 17:53
mcarrano
mcarrano previously approved these changes Feb 13, 2020
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.

This looks great!

@mattnolting
Copy link
Contributor

Really great work @kmcfaul ! Only one more thing for me:

If .pf-c-simple-list doesn't contain child .pf-c-simple-lists, you don't need role="list".

Screen Shot 2020-02-13 at 1 18 06 PM

Copy link
Contributor

@mattnolting mattnolting left a comment

Choose a reason for hiding this comment

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

🔥 LGTM! Nice work!

@jschuler jschuler merged commit 4bba16c into patternfly:master Feb 14, 2020
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • @patternfly/react-catalog-view-extension@1.3.22
  • @patternfly/react-core@3.139.0
  • @patternfly/react-docs@4.19.4
  • @patternfly/react-inline-edit-extension@2.16.21
  • demo-app-ts@3.23.0
  • @patternfly/react-integration@3.23.0
  • @patternfly/react-table@2.26.21
  • @patternfly/react-topology@2.13.21
  • @patternfly/react-virtualized-extension@1.3.116

Thanks for your contribution! 🎉

@kmcfaul kmcfaul mentioned this pull request Feb 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
css review PF4 React issues for the PF4 core effort ux approved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add experimental "Simple list" component
10 participants