if an important message appears

make sure we don't auto-close after it's resolved
fixes #2567
pull/2352/head
Mikael Finstad 9 months ago
parent 2510225408
commit 251022a298
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -43,7 +43,17 @@ function FileNameTemplateEditor(opts: {
const [validText, setValidText] = useState<string>();
const [problems, setProblems] = useState<{ error?: string | undefined, sameAsInputFileNameWarning?: boolean | undefined }>({ error: undefined, sameAsInputFileNameWarning: false });
const [fileNames, setFileNames] = useState<string[]>();
const [shown, setShown] = useState<boolean>();
const haveImportantMessage = problems.error != null || problems.sameAsInputFileNameWarning;
const [shown, setShown] = useState(haveImportantMessage);
useEffect(() => {
// if an important message appears, make sure we don't auto-close after it's resolved
// https://github.com/mifi/lossless-cut/issues/2567
if (haveImportantMessage) setShown(true);
}, [haveImportantMessage]);
const needToShow = shown || haveImportantMessage;
const inputRef = useRef<HTMLInputElement>(null);
const { t } = useTranslation();
@ -127,9 +137,6 @@ function FileNameTemplateEditor(opts: {
const onTextChange = useCallback<ChangeEventHandler<HTMLInputElement>>((e) => setText(e.target.value), []);
const haveImportantMessage = problems.error != null || problems.sameAsInputFileNameWarning;
const needToShow = shown || haveImportantMessage;
const onVariableClick = useCallback((variable: string) => {
const input = inputRef.current;
const startPos = input!.selectionStart;

Loading…
Cancel
Save