From 88302fb76475937ac9c57acccab95be273f436e3 Mon Sep 17 00:00:00 2001 From: Elisa Shapiro <83474365+ElisaShapiro@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:24:25 -0400 Subject: [PATCH] [PBNTR-600] Filter Kit - Filter Kit displaying zero results (#3799) **What does this PR do?** A clear and concise description with your runway ticket url. [PBNTR-600](https://runway.powerhrg.com/backlog_items/PBNTR-600) improves the React Filter kit's UI so it more closely matches the Rails side. Specifically, this code update allows for "Results: 0" to appear in the context of the filter kit if there are no results for a filtered search; previously, the "Results: " TitleCount component would just disappear if there were no Results. If the Filter's results prop is undefined, the "Results: " TitleCount component will not appear, which is logical behavior. **Screenshots:** Screenshots to visualize your addition/change _Screenshots on their way_ Current production behavior: Results 1+ shows "Results: 1" (first filter) but Results: 0 does not appear (second filter) react filter doc ex current if 1 or 0 New behavior for default template Filter: "Results: 0" appears react filter shows 0 New behavior for single template Filter - 0 Results and XXX Results both appear now 0 or multiple results in single template If Results prop is undefined, "Results: " will not appear undefined results in both templates Screenshot from an alpha in nitro-web on local - Results: 0 now appears on our React Basic Table Template filter local alpha showing react results 0 in templates **How to test?** Steps to confirm the desired behavior: 1. Go to review env [react filter kit default doc example](https://pr3799.playbook.beta.gm.powerapp.cloud/kits/filter/react#default)- see "Results: 0" in second filter in example. 2. Compare to current React Filter kit implementation - can test by going to [React Basic Table template](https://nitroqa.powerhrg.com/dev_docs/playbook/templates/demos/basic_table/react) and searching something that will have no results like "first name=elisashapiro". Observe how the "Results: " section just disappears. 3. Compare to Rails Filter kit behavior in current production Playbook [Rails default doc example](https://playbook.powerapp.cloud/kits/filter/rails#default) and the [Rails Basic Table template](https://nitroqa.powerhrg.com/dev_docs/playbook/templates/demos/basic_table/rails) - "Results: 0" appears for in both places. #### Checklist: - [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new kit`, `deprecated`, or `breaking`. See [Changelog & Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels) for details. - [x] **DEPLOY** I have added the `milano` label to show I'm ready for a review. ~~- [ ] **TESTS** I have added test coverage to my code.~~ --- .../app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx | 6 ++++-- .../app/pb_kits/playbook/pb_filter/docs/_filter_default.jsx | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/playbook/app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx b/playbook/app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx index 922324ed08..de66e3ed24 100644 --- a/playbook/app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx +++ b/playbook/app/pb_kits/playbook/pb_filter/Filter/ResultsCount.tsx @@ -13,6 +13,7 @@ type ResultsCountProps = { const ResultsCount = ({ dark, results, title }: ResultsCountProps): React.ReactElement => { const resultTitle = () => { + if (results == null) return null return ( { + if (results == null) return null return ( { - if (results && title) { + if (results != null && results >=0 && title) { return ( <> {resultTitle()} ) - } else if (results) { + } else if (results !=null && results >=0 ) { return ( <> {justResults()} diff --git a/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_default.jsx b/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_default.jsx index b670c057a5..f57bfa097d 100644 --- a/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_default.jsx +++ b/playbook/app/pb_kits/playbook/pb_filter/docs/_filter_default.jsx @@ -78,7 +78,7 @@ const FilterDefault = (props) => { double minWidth="375px" onSortChange={SortingChangeCallback} - results={1} + results={0} sortOptions={{ popularity: 'Popularity', // eslint-disable-next-line