Skip to content
This repository has been archived by the owner on Jan 23, 2025. It is now read-only.

Commit

Permalink
fix: add on complete close new item modal
Browse files Browse the repository at this point in the history
  • Loading branch information
spaenleh committed Mar 28, 2024
1 parent 44e62f6 commit 812e547
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/components/file/FileDashboardUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import { humanFileSize } from '../../utils/uppy';
import ErrorAlert from '../common/ErrorAlert';
import { UppyContext } from './UppyContext';

const FileDashboardUploader = (): JSX.Element => {
type Props = {
onComplete: () => void;
};
const FileDashboardUploader = ({ onComplete }: Props): JSX.Element => {
const { uppy } = useContext(UppyContext);
const { t: translateBuilder, i18n } = useBuilderTranslation();
const uppyLocales = i18n.options.resources?.[i18n.language]
Expand All @@ -28,6 +31,13 @@ const FileDashboardUploader = (): JSX.Element => {
return <ErrorAlert />;
}

// when uppy is done, notify parent
// this should close the dialog
uppy.on('complete', () => {
uppy.cancelAll();
onComplete();
});

return (
<>
<Typography variant="h6">
Expand Down
6 changes: 5 additions & 1 deletion src/components/item/header/ModeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ const ModeButton = (): JSX.Element | null => {
</IconButton>
<Menu anchorEl={anchorEl} open={open} onClose={handleClose}>
{Object.values(ItemLayoutMode).map((value) => (
<MenuItem onClick={() => handleChange(value)} value={value}>
<MenuItem
key={value}
onClick={() => handleChange(value)}
value={value}
>
{modeToIcon(value)}
</MenuItem>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/NewItemModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const NewItemModal = ({ open, handleClose }: Props): JSX.Element => {
);
case ItemType.S3_FILE:
case ItemType.LOCAL_FILE:
return <FileDashboardUploader />;
return <FileDashboardUploader onComplete={handleClose} />;
case InternalItemType.ZIP:
return <ImportZip />;
case ItemType.H5P:
Expand Down

0 comments on commit 812e547

Please sign in to comment.