From e311a22686be44819d8d399eb8cfc4cdabc742ae Mon Sep 17 00:00:00 2001 From: Domagoj Kriskovic Date: Wed, 26 Apr 2023 12:38:17 +0200 Subject: [PATCH] Merge pull request #12765 from overleaf/dk-fix-create-folder-name fix: Clear new folder input after closing modal GitOrigin-RevId: cde804212ef966f211804afc6bec1b207befeedc --- .../components/modals/file-tree-modal-create-folder.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/web/frontend/js/features/file-tree/components/modals/file-tree-modal-create-folder.js b/services/web/frontend/js/features/file-tree/components/modals/file-tree-modal-create-folder.js index 207e3444cb..aa65175d54 100644 --- a/services/web/frontend/js/features/file-tree/components/modals/file-tree-modal-create-folder.js +++ b/services/web/frontend/js/features/file-tree/components/modals/file-tree-modal-create-folder.js @@ -1,4 +1,4 @@ -import { useState } from 'react' +import { useEffect, useState } from 'react' import PropTypes from 'prop-types' import { Button, Modal } from 'react-bootstrap' @@ -21,6 +21,13 @@ function FileTreeModalCreateFolder() { const { isCreatingFolder, inFlight, finishCreatingFolder, cancel, error } = useFileTreeActionable() + useEffect(() => { + if (!isCreatingFolder) { + // clear the input when the modal is closed + setName('') + } + }, [isCreatingFolder]) + if (!isCreatingFolder) return null // the modal will not be rendered; return early function handleHide() {