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

Multiselect rewrite #743

Merged
merged 30 commits into from
Apr 11, 2023
Merged

Multiselect rewrite #743

merged 30 commits into from
Apr 11, 2023

Conversation

austensen
Copy link
Member

@austensen austensen commented Apr 9, 2023

The original multiselect library I started with for filters has turned out to be not that great - it was not originally written in typescript, it's difficult to customize, and it's not accessible for screen readers. So after struggling to add screen-reader accessibility to the existing component, I've just decided to use the much better react-select library and rewrite our custom multiselect filter.

react-select is written in typescript, has great accessibility features (nicely handles keyboard navigation for search-bar/option-list/selected-list, and has great default screen reader setting plus customization options), and it has a nice system for customizing by overwriting and recomposing its subcomponents. (The entire MultiSelect.tsx file is new, so you can just review that file alone and ignore the diff)

Since I then needed to update a lot of the filter styles for the new component, I ended up doing a much needed refactor of all the PortfolioFilters styles. I pulled out the minmax-select and multi-select styles into their one contained component styles, and also tried to simplify the organization of desktop/mobile styles to keep things close together (rather than the mostly separate mobile-specific styles nested in it's own section. I also tried to pull other changes out to component styles (Alerts, Buttons), and address some other issues at the same time.

While I was separating out the minmax-select component styles I decided to pull the component into it's own file as well (the contents haven't changed).

This all addresses a few outstanding tickets:

  • multiselect now works with screen-readers [sc-12099]
  • outline replaced with border for elements with border-radius [sc-11773]
  • fixes multiselect searchbar placeholder text alignment [sc-12186]
  • center align apply buttons on mobile [sc-12060]

@austensen austensen marked this pull request as draft April 10, 2023 01:40
@austensen austensen marked this pull request as ready for review April 10, 2023 14:07
@austensen austensen requested a review from kiwansim April 10, 2023 14:07
@austensen austensen mentioned this pull request Apr 10, 2023
@shortcut-integration
Copy link

This pull request has been linked to Shortcut Story #12060: Center align all buttons.

Copy link
Member

@kiwansim kiwansim 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 so good! tested with browserstack and looks good to me. i just have some comments that aren't going to affect functionality regardless of what you do with my thoughts! going to approve so that this merge isn't blocking the push to demo site and further VQA

selectionsCount={filterContext.filterSelections.ownernames.length}
className="ownernames-accordion"
i18n={i18n}
Copy link
Member

Choose a reason for hiding this comment

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

could the i18n just be imported in the FilterAccordion file rather than being passed as a prop? same with MultiSelect component below

align-self: flex-start;
// TODO: target area of button is still less than 44x44 px for a11y
Copy link
Member

Choose a reason for hiding this comment

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

is there a ticket for this? if so i'd err on the side of not leaving in TODO comments

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah good point - added a shortcut card to the design system collection and will remove this and others.

}
return value.toString().indexOf(search) > -1;
}
const ariaLiveGuidanceGeneral = `Type to refine list of options. Use Up and Down to choose options,
Copy link
Member

Choose a reason for hiding this comment

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

didn't know this was a thing!! 😮


// Passing custom prop to make accessible to child compnents via selectProps
const removeValue = useCallback(
// @ts-ignore (TODO: says property 'value' doesn't exist on type Option)
Copy link
Member

Choose a reason for hiding this comment

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

hm, can we extend the type Option to include the property value? kind of confused about this error

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I don't understand it either, because the Option type has value, and it knows it has this type, but for some reason it's doesn't know what the properties are.

image

At the top of this files it's defined as:

export type Option = {
  value: string;
  label: string;
  [key: string]: string;
};

Label: components.MultiValueLabel,
Remove: CustomMultiValueRemove,
}}
// TODO: Can't know when it's "focused" via arrow key navigation, it's not using ::focus,
Copy link
Member

Choose a reason for hiding this comment

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

thoughts on making github issues for the things that aren't breaking errors but would be nice to fix? unsure if that's a good use of our time but i dont know if these non-breaking errors are being kept track of anywhere. they don't feel urgent enough to be addressed right now in VQA, but I think we do need a visible log of them

Copy link
Member Author

Choose a reason for hiding this comment

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

oh yeah good point, made this (#747) and I'll remove the comment.

@austensen austensen merged commit b85c223 into filters Apr 11, 2023
@austensen austensen deleted the multiselect-rewrite branch April 11, 2023 14:45
@austensen austensen mentioned this pull request Apr 27, 2023
austensen added a commit that referenced this pull request Apr 28, 2023
austensen added a commit that referenced this pull request May 2, 2023
Previously (#743) I tried to remove i18n as a prop from some of the filters components and instead just import it in those files. However, I misunderstood exactly how this is supposed to work and since we didn't have all the translations in I didn't notice that it broke at first.

This PR fixes those issues using the proper ways to pass around the correct i18n prop without having to manually add it each time, following the examples elsewhere in wow. This makes use of <I18n> {({i18n}) => ()} </I18n> pattern for the multiselect and minmaxselect components, and the withI18nProps & withI18n() pattern for the Filters and Table components.
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.

2 participants