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(TransferList): Add transfer list component #1073

Merged
merged 121 commits into from
Jun 6, 2023
Merged

feat(TransferList): Add transfer list component #1073

merged 121 commits into from
Jun 6, 2023

Conversation

FlyersPh9
Copy link
Collaborator

@FlyersPh9 FlyersPh9 commented Feb 10, 2023

Changes

  • Introduce new TransferList component which is used to move one or more items between lists.
    <TransferList>
      <TransferList.ListboxWrapper>
        <TransferList.ListboxLabel>Listbox 1</TransferList.ListboxLabel>
        <TransferList.Listbox>
          <TransferList.Item>Item 1</TransferList.Item>          
          <TransferList.Item>Item 2</TransferList.Item>          
          <TransferList.Item>Item 3</TransferList.Item>
        </TransferList.Listbox>
      </TransferList.ListboxWrapper>
      <TransferList.Toolbar>
        <IconButton />
        <IconButton />
        <IconButton />
        <IconButton />
      </TransferList.Toolbar>
      <TransferList.ListboxWrapper>
        <TransferList.ListboxLabel>Listbox 2</TransferList.ListboxLabel>
        <TransferList.Listbox>
          <TransferList.Item>Item 4</TransferList.Item>          
          <TransferList.Item>Item 5</TransferList.Item>          
          <TransferList.Item>Item 6</TransferList.Item>
        </TransferList.Listbox>
      </TransferList.ListboxWrapper>
    </TransferList>
  );
  • Allows for use to place anything they want above / below each transfer list box (example has search & checkbox).
  • Using .iui-list from List component #1106.

Closes #634.

Testing

  • New unit tests and HTML demo page
  • Referenced w3 listbox article for accessibility best practices.

Docs

  • New changesets, website documentation, and stories added

@FlyersPh9 FlyersPh9 self-assigned this Feb 10, 2023
@FlyersPh9
Copy link
Collaborator Author

In the W3 example when hitting the tab key the focus goes to the listbox, not the individual listbox items. The user can then use the keyboard up / down keys to select an item. I think this would be preferred over how it is functioning now. For example: if the left listbox had 100+ items, it would be painful to have to tab through all 100 items before focus moves over to the right listbox.

I imagine to make that work I'll need to make these changes in this PR:

  • Add @include iui-focus to @mixin iui-menu-listbox.
  • Add tabindex="0" to <ul class="iui-menu" role="listbox">.
  • Remove tabindex="0" from all <li class="iui-menu-item" role="option">

And the rest of the functionality would be added in JS / React. Is that a correct assumption?

@FlyersPh9 FlyersPh9 marked this pull request as ready for review February 24, 2023 17:07
@FlyersPh9 FlyersPh9 requested a review from a team as a code owner February 24, 2023 17:07
@FlyersPh9 FlyersPh9 requested review from a team, mayank99 and elephantcatdog and removed request for a team February 24, 2023 17:07
@@ -35,7 +35,8 @@

.iui-input,
.iui-input-with-icon,
.iui-input-group {
.iui-input-group,
.iui-menu {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe this should be .iui-menu[role='listbox'] instead?

@FlyersPh9
Copy link
Collaborator Author

I've re-run tests on GitHub a couple of times and I keep getting 1 failure. I'm not getting the failure when running tests locally. Unsure how to get this passing.

@mayank99
Copy link
Contributor

I re-ran the tests, and CSS is passing entirely. I think the failures in React are legitimate. They are happening in the Select component, which is likely affected by your changes.

@elephantcatdog
Copy link
Contributor

The open combobox and select tests are failing because of the missing shadow/border at the bottom.
image
image

@@ -4,6 +4,10 @@

.iui-menu {
@include iui-list-menu;

.iui-listbox-wrapper & {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thank you @elephantcatdog for the tip as to what was failing. This change fixed the failed test images:

- &:where([role='listbox'])
+ .iui-listbox-wrapper & {

But depending on how #843 pans out, this may not be needed. @mayank99

@mayank99
Copy link
Contributor

mayank99 commented Mar 1, 2023

@FlyersPh9 I've created #1106, which has very minimal changes, but will allow you to use iui-list/iui-list-item classes. Take a look and then we can think on how much styling belongs in which component.

I also see some screenshots in #634 which I feel would need a bit more work.

packages/itwinui-css/backstop/tests/listbox.html Outdated Show resolved Hide resolved
packages/itwinui-css/src/listbox/listbox.scss Outdated Show resolved Hide resolved
packages/itwinui-css/src/listbox/listbox.scss Outdated Show resolved Hide resolved
Copy link
Contributor

@gretanausedaite gretanausedaite left a comment

Choose a reason for hiding this comment

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

It seems that I can't reach second ListBox with keyboard (Tab).

Screen.Recording.2023-05-24.at.12.16.02.mov

.changeset/ninety-keys-double.md Outdated Show resolved Hide resolved
<LiveExample src='TransferList.main.tsx'>
<AllExamples.TransferListMainExample client:load />
</LiveExample>

Copy link
Contributor

Choose a reason for hiding this comment

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

Can be done in future PRs: We need to give more info for our users about this component.

@mayank99
Copy link
Contributor

Reposting #1073 (comment) for visibility:

Both of ListboxLabels gets the same labelId and ListBoxes are not described correctly. Example I'm using:
image

"Avalable" listbox
image

"Selected" listbox
image

@adamhock
Copy link
Contributor

Reposting #1073 (comment) for visibility:

Both of ListboxLabels gets the same labelId and ListBoxes are not described correctly. Example I'm using:
image
"Avalable" listbox
image
"Selected" listbox
image

This has been fixed

@adamhock
Copy link
Contributor

It seems that I can't reach second ListBox with keyboard (Tab).

I have fixed this by adding tabIndex={0} to TransferList.Listbox

Copy link
Contributor

@gretanausedaite gretanausedaite left a comment

Choose a reason for hiding this comment

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

Looks good to me 🌵

@adamhock adamhock requested review from a team as code owners June 1, 2023 16:37
@adamhock adamhock requested review from adamhock and removed request for a team June 1, 2023 16:37
Copy link
Contributor

@mayank99 mayank99 left a comment

Choose a reason for hiding this comment

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

LGTM

@adamhock adamhock added this to the React 3.0 milestone Jun 5, 2023
@adamhock adamhock added this pull request to the merge queue Jun 6, 2023
Merged via the queue into dev with commit 406872a Jun 6, 2023
@adamhock adamhock deleted the jon/listbox branch June 6, 2023 01:10
@imodeljs-admin imodeljs-admin mentioned this pull request Oct 23, 2023
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 listbox / transfer list component
5 participants