-
Notifications
You must be signed in to change notification settings - Fork 497
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(refinementList): show more count #5593
Open
mikedavis77
wants to merge
41
commits into
master
Choose a base branch
from
feat/refinement-list-show-more-count
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
0a17972
feat(refinementList): show more count
52c3811
feat(refinementList): updated react test
86c4020
feat(refinementList): updated count check
cdae18c
feat(refinementList): updated tests
fed1d7c
Merge branch 'master' into feat/refinement-list-show-more-count
mikedavis77 b4ce94b
feat(refinementList): Applied change to hierarchicalMenu & menu
2c0b70f
feat(refinementList): updated tests
bf50452
feat(refinementList): updated tests
a84d505
feat(refinementList): updated storybook
a68b0ac
feat(refinementList): show more count
b3b77e3
feat(refinementList): updated react test
8a97806
feat(refinementList): updated count check
b06f2ad
feat(refinementList): updated tests
f78041b
feat(refinementList): Applied change to hierarchicalMenu & menu
ab54c9d
feat(refinementList): updated tests
ef3b18a
feat(refinementList): updated tests
0a8dd3b
Merge branch 'feat/refinement-list-show-more-count' of github.com:alg…
68e1d24
feat(refinementList): added new tests
f4a82b6
Merge branch 'master' into feat/refinement-list-show-more-count
mikedavis77 21fadcf
feat(refinementList): added new tests
af8a5fa
Apply suggestions from code review
mikedavis77 c6be31f
fix lint errors
5aa3037
updated Vue package with showMoreCount
e98802a
Merge branch 'master' into feat/refinement-list-show-more-count
mikedavis77 666e359
feat(refinementList): show more count
22e7ef7
feat(refinementList): updated react test
08b9e2b
feat(refinementList): updated count check
e6151fc
feat(refinementList): updated tests
bd85946
feat(refinementList): Applied change to hierarchicalMenu & menu
edd04bb
feat(refinementList): updated tests
c16b4b7
feat(refinementList): updated tests
f1282a7
feat(refinementList): updated storybook
3bc5eea
merge conflict from rebase
92977be
feat(refinementList): updated count check
188f752
feat(refinementList): added new tests
493912f
feat(refinementList): added new tests
4875312
Apply suggestions from code review
mikedavis77 50c41fb
fix lint errors
b00aa8b
updated Vue package with showMoreCount
2a562d2
Merge branch 'feat/refinement-list-show-more-count' of github.com:alg…
825f8be
refactoring: move show more count tests to common suite (#5638)
dhayab File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,10 @@ export type MenuRenderState = { | |
* True if the menu is displaying all the menu items. | ||
*/ | ||
isShowingMore: boolean; | ||
/** | ||
* Total number of facet values that can be displayed for 'show more'. | ||
*/ | ||
showMoreCount: number; | ||
/** | ||
* Toggles the number of values displayed between `limit` and `showMore.limit`. | ||
*/ | ||
|
@@ -182,6 +186,7 @@ const connectMenu: MenuConnector = function connectMenu( | |
// Provide the same function to the `renderFn` so that way the user | ||
// has to only bind it once when `isFirstRendering` for instance | ||
let isShowingMore = false; | ||
let showMoreCount = 0; | ||
let toggleShowMore = () => {}; | ||
function createToggleShowMore( | ||
renderOptions: RenderOptions, | ||
|
@@ -289,6 +294,7 @@ const connectMenu: MenuConnector = function connectMenu( | |
} | ||
|
||
if (results) { | ||
const currentLimit = getLimit(); | ||
const facetValues = results.getFacetValues(attribute, { | ||
sortBy, | ||
facetOrdering: sortBy === DEFAULT_SORT, | ||
|
@@ -298,12 +304,20 @@ const connectMenu: MenuConnector = function connectMenu( | |
? facetValues.data | ||
: []; | ||
|
||
if (showMore) { | ||
const showMoreTotalCount = Math.min( | ||
showMoreLimit, | ||
facetItems.length | ||
); | ||
showMoreCount = showMoreTotalCount - currentLimit; | ||
Comment on lines
+308
to
+312
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if the number given to the template shouldn't be |
||
} | ||
|
||
canToggleShowMore = | ||
showMore && (isShowingMore || facetItems.length > getLimit()); | ||
showMore && (isShowingMore || facetItems.length > currentLimit); | ||
|
||
items = transformItems( | ||
facetItems | ||
.slice(0, getLimit()) | ||
.slice(0, currentLimit) | ||
.map(({ name: label, escapedValue: value, path, ...item }) => ({ | ||
...item, | ||
label, | ||
|
@@ -321,6 +335,7 @@ const connectMenu: MenuConnector = function connectMenu( | |
canRefine: items.length > 0, | ||
widgetParams, | ||
isShowingMore, | ||
showMoreCount, | ||
toggleShowMore: cachedToggleShowMore, | ||
canToggleShowMore, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should probably be a test where showMoreCount isn't 0