-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat: Story map chapter move #1175
Changes from 13 commits
b162e42
20022d6
2106450
4b641bd
8b568a0
5e64056
fb03ba9
6a97c01
3627b98
d33cc15
4f86f3c
c4260a3
25ce9e6
9278c11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright © 2021-2023 Technology Matters | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see https://www.gnu.org/licenses/. | ||
*/ | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
import { MenuItem } from '@mui/material'; | ||
|
||
import ConfirmationDialog from 'common/components/ConfirmationDialog'; | ||
|
||
const ConfirmMenuItem = props => { | ||
const [openConfirmation, setOpenConfirmation] = useState(false); | ||
const { confirmTitle, confirmMessage, confirmButton, onConfirm, children } = | ||
props; | ||
|
||
useEffect(() => { | ||
setOpenConfirmation(false); | ||
}, []); | ||
|
||
const onClick = useCallback(event => { | ||
setOpenConfirmation(true); | ||
event.stopPropagation(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question: I'm not super familiar with the web client code, is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @david-code yes, I think that is common, there are some cases where you have the same listener on a parent component and you want to avoid the event to keep propagating |
||
}, []); | ||
|
||
const onCancel = useCallback(event => { | ||
setOpenConfirmation(false); | ||
event.stopPropagation(); | ||
}, []); | ||
|
||
return ( | ||
<> | ||
<ConfirmationDialog | ||
open={openConfirmation} | ||
title={confirmTitle} | ||
message={confirmMessage} | ||
confirmButtonLabel={confirmButton} | ||
onCancel={onCancel} | ||
onConfirm={onConfirm} | ||
/> | ||
<MenuItem onClick={onClick}>{children}</MenuItem> | ||
</> | ||
); | ||
}; | ||
|
||
export default ConfirmMenuItem; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { Droppable } from 'react-beautiful-dnd'; | ||
|
||
// Work around for react-beautiful-dnd issue. The issues is that the | ||
// Droppable component is not compatible with React.StrictMode. | ||
// StricMode is used in the development environment by default. | ||
// See: | ||
// - https://stackoverflow.com/a/75807063 | ||
// - https://github.com/atlassian/react-beautiful-dnd/issues/2396 | ||
const StrictModeDroppable = ({ children, ...props }) => { | ||
const [enabled, setEnabled] = useState(false); | ||
useEffect(() => { | ||
const animation = requestAnimationFrame(() => setEnabled(true)); | ||
return () => { | ||
cancelAnimationFrame(animation); | ||
setEnabled(false); | ||
}; | ||
}, []); | ||
if (!enabled) { | ||
return null; | ||
} | ||
return <Droppable {...props}>{children}</Droppable>; | ||
}; | ||
|
||
export default StrictModeDroppable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion+nit: I don't think this needs to be set
false
here, I think that is the default value it will have.