Skip to content

Commit

Permalink
HPCC-31169 Add "padding" option for Dock Panel children
Browse files Browse the repository at this point in the history
Fix issue when child item in undefined

Signed-off-by: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Jan 24, 2024
1 parent 882fad4 commit 9ea8105
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions esp/src/src-react/layouts/DockPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ interface DockPanelItemProps {
location?: "split-top" | "split-left" | "split-right" | "split-bottom" | "tab-before" | "tab-after";
relativeTo?: string;
closable?: boolean | IClosable;
padding?: number;
children: JSX.Element;
}

Expand All @@ -174,7 +175,7 @@ export const DockPanel: React.FunctionComponent<DockPanelProps> = ({
}) => {
const items = React.useMemo(() => {
if (children === undefined) return [];
return Array.isArray(children) ? children : [children];
return (Array.isArray(children) ? children : [children]).filter(item => !!item);
}, [children]);
const [prevItems, setPrevItems] = React.useState<React.ReactElement<DockPanelItemProps>[]>([]);
const { theme, themeV9 } = useUserTheme();
Expand All @@ -201,8 +202,10 @@ export const DockPanel: React.FunctionComponent<DockPanelProps> = ({
dockPanel.removeWidget(idx.get(item.key));
});
diffs.enter.forEach(item => {
const reactWidget = new ReactWidget().id(item.key);
dockPanel.addWidget(reactWidget, item.props.title, item.props.location, idx.get(item.props.relativeTo), item.props.closable);
const reactWidget = new ReactWidget()
.id(item.key)
;
dockPanel.addWidget(reactWidget, item.props.title, item.props.location, idx.get(item.props.relativeTo), item.props.closable, item.props.padding);
idx.set(item.key, reactWidget);
});
[...diffs.enter, ...diffs.update].forEach(item => {
Expand Down

0 comments on commit 9ea8105

Please sign in to comment.