Skip to content

Commit

Permalink
fix: number of categories counter when some are blocked on Category W…
Browse files Browse the repository at this point in the history
…idget
  • Loading branch information
AdriSolid authored Feb 5, 2021
1 parent 7cf5c8f commit 2a94d5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fix an issue on histogram's operations when processing a not finite value [#79](https://github.com/CartoDB/carto-react-lib/pull/79)
- Add sourcemaps and production mode in webpack bundles [#83](https://github.com/CartoDB/carto-react-lib/pull/83)
- Fix number of categories counter when some are locked on Category Widget [#81](https://github.com/CartoDB/carto-react-lib/pull/81)

## 1.0.0-beta13 (2021-02-02)

Expand Down
7 changes: 6 additions & 1 deletion src/ui/widgets/CategoryWidgetUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,11 @@ function CategoryWidgetUI(props) {
return () => cancelAnimationFrame(requestRef.current);
}, [sortedData]);

const getCategoriesCount = useCallback(() => {
const blocked = blockedCategories.length;
return blocked ? data.length - blocked : data.length - maxItems;
}, [data, maxItems, blockedCategories]);

// Separated to simplify the widget layout but inside the main component to avoid passing all dependencies
const CategoryItem = (props) => {
const { data, onCategoryClick } = props;
Expand Down Expand Up @@ -528,7 +533,7 @@ function CategoryWidgetUI(props) {
startIcon={<SearchIcon />}
onClick={handleShowAllCategoriesClicked}
>
Search in {data.length - maxItems} elements
Search in {getCategoriesCount()} elements
</Button>
)
) : null}
Expand Down

0 comments on commit 2a94d5d

Please sign in to comment.