Skip to content

Commit

Permalink
WrapperWidgetUI support externally controlled expanded attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
zbigg committed Apr 11, 2022
1 parent fd77cb8 commit 2e43a9b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Not released

- WrapperWidgetUI support externally controlled `expanded` attribute [#376](https://github.com/CartoDB/carto-react/pull/376)
- Bump deck.gl to 8.7.3 [#360](https://github.com/CartoDB/carto-react/pull/360)
- Fix aggregation to ignore NULL values [#367](https://github.com/CartoDB/carto-react/pull/367)
- Fix regression for PieWidgetUI category selection logic [#369](https://github.com/CartoDB/carto-react/pull/369)
Expand Down
2 changes: 2 additions & 0 deletions packages/react-ui/src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export type WrapperWidgetUI = {
title: string;
isLoading?: boolean;
expandable?: boolean;
expanded?: boolean;
setExpanded?: (v: boolean) => void;
actions?: { id: string; name: string; icon: React.ReactElement; action: Function }[];
options?: { id: string; name: string; action: Function }[];
children?: React.ReactNode;
Expand Down
4 changes: 3 additions & 1 deletion packages/react-ui/src/widgets/WrapperWidgetUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ const useStyles = makeStyles((theme) => ({

function WrapperWidgetUI(props) {
const wrapper = createRef();
const [expanded, setExpanded] = useState(true);
const [expandedInt, setExpandedInt] = useState(true);
const expanded = props.expandable !== false ? props.expanded ?? expandedInt : true;
const setExpanded = props.setExpanded ?? setExpandedInt;
const [anchorEl, setAnchorEl] = useState(null);
const classes = useStyles({ ...props, expanded });
const open = Boolean(anchorEl);
Expand Down

0 comments on commit 2e43a9b

Please sign in to comment.