Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(List): add horizontal prop #1721

Merged
merged 9 commits into from
Jul 31, 2019
Merged

feat(List): add horizontal prop #1721

merged 9 commits into from
Jul 31, 2019

Conversation

mnajdova
Copy link
Contributor

@mnajdova mnajdova commented Jul 26, 2019

Added horizontal prop to the List component. This prop is considered in the keyboard navigation of the selectable List.

@codecov
Copy link

codecov bot commented Jul 26, 2019

Codecov Report

Merging #1721 into master will increase coverage by 0.07%.
The diff coverage is 78.94%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1721      +/-   ##
==========================================
+ Coverage   70.98%   71.05%   +0.07%     
==========================================
  Files         860      860              
  Lines        7156     7170      +14     
  Branches     2058     2082      +24     
==========================================
+ Hits         5080     5095      +15     
+ Misses       2070     2069       -1     
  Partials        6        6
Impacted Files Coverage Δ
packages/react/src/components/List/List.tsx 59.25% <ø> (ø) ⬆️
...c/lib/accessibility/Behaviors/List/listBehavior.ts 100% <ø> (ø) ⬆️
...act/src/themes/teams/components/List/listStyles.ts 20% <0%> (+3.33%) ⬆️
...ages/react/test/specs/behaviors/testDefinitions.ts 93.41% <100%> (+0.32%) ⬆️
...ssibility/Behaviors/List/selectableListBehavior.ts 100% <100%> (ø) ⬆️

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 06cd244...9c7a8aa. Read the comment docs.

@lucivpav
Copy link
Contributor

Since the default value of vertical is true, wouldn't it be more user-friendly, if we would specify horizontal instead? E.g. <List horizontal> or <List horizontal={true}>?

@mnajdova
Copy link
Contributor Author

@lucivpav that's a good point, but I chose the vertical only because we have that as a term in other components too. I think it will be easier for users to just learn that one prop, rather than remember where they should provide the vertical, and where the horizontal prop. Is this strong enough reason for you? :)

@lucivpav
Copy link
Contributor

@lucivpav that's a good point, but I chose the vertical only because we have that as a term in other components too. I think it will be easier for users to just learn that one prop, rather than remember where they should provide the vertical, and where the horizontal prop. Is this strong enough reason for you? :)

Yes, it makes very good sense now :)

* Triggers 'moveNext' action with 'ArrowDown' on 'root', when orientation is vertical.
* Triggers 'moveNext' action with 'ArrowRight' on 'root', when orientation is horizontal.
* Triggers 'movePrevious' action with 'ArrowUp' on 'root', when orientation is vertical.
* Triggers 'movePrevious' action with 'ArrowLeft' on 'root', when orientation is horizontal.
* Triggers 'moveFirst' action with 'Home' on 'root'.
* Triggers 'moveLast' action with 'End' on 'root'.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please add "aria-orientation" attribute(on the root element, under line 19), based on the aria:
https://www.w3.org/TR/wai-aria-practices/#Listbox
If options are arranged horizontally, the element with role listbox has aria-orientation set to horizontal. The default value of aria-orientation for listbox is vertical.

Thank you :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, please take a look and propose how we can test it :\

]

const ListExampleSelectable = () => (
<List selectable defaultSelectedIndex={0} items={items} vertical={false} />
Copy link
Member

Choose a reason for hiding this comment

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

Propose we use horizontal instead. This is because the default list is expected to be vertical and the descriptive alternative is one that is horizontal.

This is similar to why there is an HTML attribute for disabled and not enabled="false".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, my reasoning was that we already have the vertical prop, so users will have to think about before applying vertical/horizontal on different components, based on how they appear by default...

},
root: ({ props: p }): ICSSInJSStyle => ({
...(p.debug && debugRoot()),
display: p.vertical ? 'block' : 'flex',
Copy link
Member

Choose a reason for hiding this comment

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

What's the reasoning on horizontal lists being block level elements vs inline elements (inline-flex)? What's use cases are we targeting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No strong reasoning for this, I was just following the paradigm we had before. inline-flex works as expected as well, and may be even better to the usecases we have, something like this:
image

Will change it

-updated behavior description
@mnajdova mnajdova changed the title feat(List): add vertical prop feat(List): add horizontal prop Jul 31, 2019
@vercel vercel bot temporarily deployed to staging July 31, 2019 08:36 Inactive
@mnajdova mnajdova merged commit b06f6b3 into master Jul 31, 2019
@delete-merged-branch delete-merged-branch bot deleted the feat/list-vertical-prop branch July 31, 2019 09:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants