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

<Collection> improvements: isPagination/isSearchable #507

Merged
merged 9 commits into from
Oct 27, 2021

Conversation

hvergara
Copy link
Contributor

@hvergara hvergara commented Oct 13, 2021

Description of changes:
Introducing search & pagination capabilities for <Collection> components

collections.mov

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@hvergara hvergara force-pushed the collection-improvements branch from 71762eb to ab5bca1 Compare October 15, 2021 06:14
@hvergara hvergara marked this pull request as ready for review October 15, 2021 06:17
@hvergara hvergara temporarily deployed to ci October 15, 2021 06:21 Inactive
@hvergara hvergara temporarily deployed to ci October 15, 2021 06:21 Inactive
@hvergara hvergara temporarily deployed to ci October 15, 2021 06:21 Inactive
@hvergara hvergara temporarily deployed to ci October 15, 2021 20:29 Inactive
@hvergara hvergara temporarily deployed to ci October 15, 2021 20:29 Inactive
@hvergara hvergara temporarily deployed to ci October 15, 2021 20:29 Inactive
@hvergara hvergara added the pending-review An issue or a feature PR is pending review prior to release label Oct 19, 2021
@hvergara hvergara temporarily deployed to ci October 19, 2021 05:36 Inactive
@hvergara hvergara temporarily deployed to ci October 19, 2021 05:36 Inactive
@hvergara hvergara temporarily deployed to ci October 19, 2021 05:36 Inactive
@hvergara hvergara temporarily deployed to ci October 19, 2021 23:27 Inactive
@hvergara hvergara temporarily deployed to ci October 19, 2021 23:27 Inactive
@hvergara hvergara temporarily deployed to ci October 19, 2021 23:27 Inactive
Copy link
Contributor

@reesscot reesscot 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, left some comments below


TBD
Collections can also be filtered, adding a `isSearchable` property. Pass a custom `searchFilter` function to enhance your search experience.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we explain what the default search function is, or do they have to provide a search function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

return (
<Flex direction={direction} className={className} {...rest}>
{Array.isArray(items) && items.map(children)}
<Flex direction="column">
Copy link
Contributor

Choose a reason for hiding this comment

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

These style props should be moved to CSS so they aren't render time styling. Should also provide a class name and take in a class name for customers to hook into.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good idea, will add in next commit

{Array.isArray(items) && items.map(children)}
<Flex direction="column">
{isSearchable && (
<Flex direction="row" justifyContent="center">
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above on moving style props styling to CSS file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in next revision

{isSearchable && (
<Flex direction="row" justifyContent="center">
<SearchField
size="small"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be customizable by the user? What if the customer wants a different size or variation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed in next revision

<Flex direction="row" justifyContent="center">
<SearchField
size="small"
label="Search"
Copy link
Contributor

Choose a reason for hiding this comment

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

This string should be in the i18n file so we don't have to go looking for it later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in next revision

@@ -14,6 +14,7 @@ export const Pagination: Primitive<PaginationProps, 'nav'> = ({
onNext,
onPrevious,
onChange,
role = 'navigation',
...rest
}) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this already the implicit role in a nav 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.

true, will remove in next commit

}
if (key === ENTER_KEY) {
onClearHandler();
} else if (key === ENTER_KEY) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why else if? What's wrong with just if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

key cannot be ENTER_KEY and ESCAPE at the same time

@@ -68,13 +77,16 @@ export const SearchField: Primitive<SearchFieldProps, 'input'> = ({
className,
labelHidden = true,
label,
name = 'q',
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove the default name? Without a name, the field value won't be submitted from within a form.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, will restore in next commit

@@ -68,13 +77,16 @@ export const SearchField: Primitive<SearchFieldProps, 'input'> = ({
className,
labelHidden = true,
label,
name = 'q',
name,
role = 'searchbox',
Copy link
Contributor

Choose a reason for hiding this comment

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

I did some research on this and I don't think we should add this role here. I don't see role="searchbox" being used on any other search fields that I can find in the wild, and it actually has some drawbacks (see: w3c/aria-practices#1903)

From this comment it sounds like it would force the screen reader to read 'search' multiple times if the accessible name also has 'search' in it, which isn't very user friendly.

I think this is a case where applying "no ARIA is better than bad ARIA" rule of thumb makes sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, fixed in next revision

ListCollectionProps<CollectionType>;
export type CollectionProps<Item> = CollectionWrapperProps &
(
| ({ type: 'list' } & ListCollectionProps<Item>)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why move the { type: 'list' } down here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

cause I don't want to expose the type property to ListCollection or GridCollection props.

@hvergara hvergara temporarily deployed to ci October 25, 2021 22:29 Inactive
@hvergara hvergara temporarily deployed to ci October 25, 2021 22:29 Inactive
@hvergara hvergara temporarily deployed to ci October 25, 2021 22:29 Inactive
@hvergara hvergara temporarily deployed to ci October 27, 2021 03:01 Inactive
@hvergara hvergara temporarily deployed to ci October 27, 2021 03:01 Inactive
@hvergara hvergara temporarily deployed to ci October 27, 2021 03:01 Inactive
Copy link
Contributor

@reesscot reesscot left a comment

Choose a reason for hiding this comment

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

Shipit!

@hvergara hvergara merged commit 9f94bc3 into main Oct 27, 2021
@hvergara hvergara deleted the collection-improvements branch October 27, 2021 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending-review An issue or a feature PR is pending review prior to release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants