Skip to content

Commit

Permalink
[Fixes 1122] Issues with pressing Enter in Clone dialog (#1133) (#1140)
Browse files Browse the repository at this point in the history
* Fixes 1122

* Added enter for new maps
  • Loading branch information
DavidQuartz authored Aug 5, 2022
1 parent 1246727 commit 8f53b49
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions geonode_mapstore_client/client/js/plugins/save/SaveModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,30 +64,25 @@ function SaveModal({

const isLoading = loading || saving;


useEffect(() => {
// clone on enter key press
if (copy && currentModal?.current) {
currentModal?.current?.addEventListener('keyup', (event) => {
if (event.keyCode === 13) {
event.stopPropagation();
onSave(
update ? contentId : undefined,
{
thumbnail,
name,
description
},
true);
}
});
}
return () => currentModal?.current?.removeEventListener('keyup', () => {});
}, []);
const handleEnterPress = options => {
const {title, isUpdate, content, image, text, reload} = options;
return onSave(
isUpdate ? content : undefined,
{
thumbnail: image,
name: title,
description: text
},
reload);
};

return (
<Portal>
<div ref={currentModal}>
<div ref={currentModal} onKeyUp={(e) => {
e.stopPropagation();
return (e.keyCode === 13 || e.code === 'Enter') && (copy ? handleEnterPress({title: name, isUpdate: update, content: contentId, image: thumbnail, text: description, reload: false}) : handleEnterPress({title: name, isUpdate: update, content: contentId, image: thumbnail, text: description, reload: true}));
}
}>
<ResizableModal
title={<Message msgId={labelId}/>}
show={enabled}
Expand Down Expand Up @@ -122,7 +117,8 @@ function SaveModal({
{success && <Alert bsStyle="success" style={{ margin: 0 }}>
<div><Message msgId="saveDialog.saveSuccessMessage" /></div>
</Alert>}
<Form>
{/* prevent reload on enter key press from implicit submission */}
<Form onSubmit={(e) => e.preventDefault()}>
<FormGroup
validationState={nameValidation}
>
Expand Down

0 comments on commit 8f53b49

Please sign in to comment.