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

fix: update title on first page load #157

Merged
merged 2 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions src/components/EditorHeader/ControlPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ export default function ControlPanel({
}) {
const [modal, setModal] = useState(MODAL.NONE);
const [sidesheet, setSidesheet] = useState(SIDESHEET.NONE);
const [prevTitle, setPrevTitle] = useState(title);
const [showEditName, setShowEditName] = useState(false);
const [importDb, setImportDb] = useState("");
const [exportData, setExportData] = useState({
Expand Down Expand Up @@ -728,7 +727,6 @@ export default function ControlPanel({
rename: {
function: () => {
setModal(MODAL.RENAME);
setPrevTitle(title);
},
},
delete_diagram: {
Expand Down Expand Up @@ -1309,10 +1307,8 @@ export default function ControlPanel({
setExportData={setExportData}
title={title}
setTitle={setTitle}
setPrevTitle={setPrevTitle}
setDiagramId={setDiagramId}
setModal={setModal}
prevTitle={prevTitle}
importDb={importDb}
/>
<Sidesheet
Expand Down
11 changes: 6 additions & 5 deletions src/components/EditorHeader/Modal/Modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ export default function Modal({
setModal,
title,
setTitle,
prevTitle,
setPrevTitle,
setDiagramId,
exportData,
setExportData,
Expand All @@ -65,6 +63,7 @@ export default function Modal({
const { setTasks } = useTasks();
const { setTransform } = useTransform();
const { setUndoStack, setRedoStack } = useUndoRedo();
const [uncontrolledTitle, setUncontrolledTitle] = useState(title);
const [importSource, setImportSource] = useState({
src: "",
overwrite: true,
Expand Down Expand Up @@ -212,7 +211,7 @@ export default function Modal({
setModal(MODAL.NONE);
return;
case MODAL.RENAME:
setPrevTitle(title);
setTitle(uncontrolledTitle);
setModal(MODAL.NONE);
return;
case MODAL.SAVEAS:
Expand Down Expand Up @@ -256,7 +255,9 @@ export default function Modal({
/>
);
case MODAL.RENAME:
return <Rename title={title} setTitle={setTitle} />;
return (
<Rename key={title} title={title} setTitle={setUncontrolledTitle} />
);
case MODAL.OPEN:
return (
<Open
Expand Down Expand Up @@ -339,7 +340,7 @@ export default function Modal({
});
}}
onCancel={() => {
if (modal === MODAL.RENAME) setTitle(prevTitle);
if (modal === MODAL.RENAME) setUncontrolledTitle(title);
setModal(MODAL.NONE);
}}
centered
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorHeader/Modal/Rename.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function Rename({ title, setTitle }) {
return (
<Input
placeholder={t("name")}
value={title}
defaultValue={title}
onChange={(v) => setTitle(v)}
/>
);
Expand Down
Loading