Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-pumas-happen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cube-dev/ui-kit': patch
---

Fixes false error in useDialogContainer.
18 changes: 12 additions & 6 deletions src/components/overlays/Dialog/dialog-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,26 @@ export function useDialogContainer<
const [containerProps, setContainerProps] = useState<E | null>(null);
const setupRef = useRef(false);

function setupCheck() {
if (!setupRef.current) {
throw new Error(
'useDialogContainer: DialogContainer must be rendered. Use `rendered` property to include it in your component tree.',
);
}
}

// 'open' accepts props required by the Component and opens the dialog
const open = useEvent((props: P, containerProps?: E) => {
setupCheck();

setComponentProps(props);
setContainerProps(containerProps ?? null);
setIsOpen(true);
});

const update = useEvent((props: P, containerProps?: E) => {
setupCheck();

setComponentProps(props);
setContainerProps(containerProps ?? null);
});
Expand All @@ -43,12 +55,6 @@ export function useDialogContainer<

// Render the dialog only when componentProps is set
const renderedDialog = useMemo(() => {
if (!setupRef.current) {
throw new Error(
'useDialogContainer: DialogContainer must be rendered. Use `rendered` property to include it in your component tree.',
);
}

if (!componentProps) return null;

return (
Expand Down
Loading