diff --git a/client/modules/App/components/Overlay.tsx b/client/modules/App/components/Overlay.tsx
index a8bac53d3a..76cb2a56c9 100644
--- a/client/modules/App/components/Overlay.tsx
+++ b/client/modules/App/components/Overlay.tsx
@@ -15,6 +15,7 @@ type OverlayProps = {
title?: string;
ariaLabel?: string;
isFixedHeight?: boolean;
+ isCompactHeight?: boolean;
};
export const Overlay = ({
@@ -22,6 +23,7 @@ export const Overlay = ({
ariaLabel = 'modal',
children,
closeOverlay,
+ isCompactHeight = false,
isFixedHeight = false,
title = 'Modal'
}: OverlayProps) => {
@@ -43,8 +45,7 @@ export const Overlay = ({
if (!node) return;
// Only close if it is the last (and therefore the topmost overlay)
const overlays = document.getElementsByClassName('overlay');
- if (node.parentElement?.parentElement !== overlays[overlays.length - 1])
- return;
+ if (node.closest('.overlay') !== overlays[overlays.length - 1]) return;
if (!closeOverlay) {
browserHistory.push(previousPath);
@@ -57,7 +58,9 @@ export const Overlay = ({
return (
{
+ event.stopPropagation();
+ close();
+ }}
aria-label={t('Overlay.AriaLabel', { title })}
>
diff --git a/client/modules/IDE/actions/collections.js b/client/modules/IDE/actions/collections.js
index 68a42f500d..8789fdcd63 100644
--- a/client/modules/IDE/actions/collections.js
+++ b/client/modules/IDE/actions/collections.js
@@ -34,7 +34,7 @@ export function getCollections(username) {
};
}
-export function createCollection(collection) {
+export function createCollection(collection, redirect = true) {
return (dispatch) => {
dispatch(startLoader());
const url = '/collections';
@@ -52,8 +52,9 @@ export function createCollection(collection) {
const pathname = `/${newCollection.owner.username}/collections/${newCollection.id}`;
const location = { pathname, state: { skipSavingPath: true } };
-
- browserHistory.push(location);
+ if (redirect) {
+ browserHistory.push(location);
+ }
})
.catch((error) => {
dispatch({
diff --git a/client/modules/IDE/components/AddToCollectionList.jsx b/client/modules/IDE/components/AddToCollectionList.jsx
index 75713367ee..4c45193e81 100644
--- a/client/modules/IDE/components/AddToCollectionList.jsx
+++ b/client/modules/IDE/components/AddToCollectionList.jsx
@@ -13,6 +13,9 @@ import {
import getSortedCollections from '../selectors/collections';
import QuickAddList from './QuickAddList';
import { remSize } from '../../../theme';
+import { Overlay } from '../../App/components/Overlay';
+import CollectionCreate from '../../User/components/CollectionCreate';
+import { Button } from '../../../common/Button';
export const CollectionAddSketchWrapper = styled.div`
width: ${remSize(600)};
@@ -40,10 +43,11 @@ const AddToCollectionList = ({ projectId }) => {
const loading = useSelector((state) => state.loading);
const [hasLoadedData, setHasLoadedData] = useState(false);
const showLoader = loading && !hasLoadedData;
+ const [createCollectionVisible, setCreateCollectionVisible] = useState(false);
useEffect(() => {
dispatch(getCollections(username)).then(() => setHasLoadedData(true));
- }, [dispatch, username]);
+ }, [dispatch, username, createCollectionVisible]);
const handleCollectionAdd = (collection) => {
dispatch(addToCollection(collection.id, projectId));
@@ -80,6 +84,19 @@ const AddToCollectionList = ({ projectId }) => {
{t('AddToCollectionList.Title')}
+
+
+ {createCollectionVisible && (
+ setCreateCollectionVisible(false)}
+ isCompactHeight
+ >
+
+
+ )}
{getContent()}
diff --git a/client/modules/User/components/CollectionCreate.jsx b/client/modules/User/components/CollectionCreate.jsx
index 47021c8e08..ce3e661fcf 100644
--- a/client/modules/User/components/CollectionCreate.jsx
+++ b/client/modules/User/components/CollectionCreate.jsx
@@ -24,7 +24,8 @@ const CollectionCreate = () => {
const handleCreateCollection = (event) => {
event.preventDefault();
- dispatch(createCollection({ name, description }));
+ // second argument is redirect flag, set to false to avoid redirect
+ dispatch(createCollection({ name, description }, false));
};
const invalid = name === '' || name == null;