FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat(SimpleList): add simple list by kmcfaul · Pull Request #3645 · patternfly/patternfly-react · GitHub

feat(SimpleList): add simple list - #3645

Merged
jschuler merged 12 commits into
patternfly:masterfrom
kmcfaul:simple-list
Feb 14, 2020
Merged

feat(SimpleList): add simple list#3645
jschuler merged 12 commits into
patternfly:masterfrom
kmcfaul:simple-list

Conversation

kmcfaul commented Feb 3, 2020

Copy link
Copy Markdown
Contributor

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.

patternfly-build commented Feb 3, 2020
edited
Loading

Copy link
Copy Markdown
Collaborator

mcoker commented Feb 3, 2020

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

mcarrano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

kmcfaul commented Feb 4, 2020

Copy link
Copy Markdown
Contributor Author

@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 commented Feb 4, 2020
edited
Loading

Copy link
Copy Markdown

Codecov Report

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

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

mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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.


...

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

mcarrano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

mcoker commented Feb 5, 2020

Copy link
Copy Markdown
Contributor

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

mcoker commented Feb 8, 2020

Copy link
Copy Markdown
Contributor

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

kmcfaul commented Feb 10, 2020

Copy link
Copy Markdown
Contributor Author

@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 previously approved these changes Feb 12, 2020

dlabrecq left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

should extend HTMLProps for section

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I could only find React.HTMLProps<HTMLTableSectionElement>, would this be correct? It seems to work with the console logging warnings

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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


const componentProps = isButton
? {
type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

className should be on the root element

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

jessiehuff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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:

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

jessiehuff left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM! :)

dlabrecq previously approved these changes Feb 13, 2020

mattnolting left a comment
edited
Loading

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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>

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

mcarrano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This looks great!

Copy link
Copy Markdown
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".

mattnolting left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🔥 LGTM! Nice work!

jschuler merged commit 4bba16c into patternfly:master Feb 14, 2020

Copy link
Copy Markdown
Collaborator

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 mentioned this pull request Feb 14, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Add experimental "Simple list" component

10 participants


Back | FazBrowse Home | New Git URL