Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 4.x][Fixes 1122] Issues with pressing Enter in Clone dialog #1140

Merged
merged 1 commit into from
Aug 5, 2022
Merged
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
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