mirror of
https://github.com/documenso/documenso.git
synced 2025-11-10 04:22:32 +10:00
fix(webapp): reset delete document dialog (#762)
This PR makes a small but useful tweak to the `DeleteDocumentDialog`. Now, the input field gets cleared whenever the dialog is opened. Here’s what’s changed: 1. **Clear Field After Deleting**: After you delete something and open the dialog again, it won’t show the old, deleted text anymore. It’s clean and ready for the next delete. 2. **Type Again to Confirm**: If you type something but close the dialog without deleting, you’ll have to type it again next time. This way, it makes sure the user really mean to delete something and didn't do it by mistake. Demo Link: See the old vs. new in action here: https://www.loom.com/share/80eca0d3b1994f7cbcab6f222db2dbfe?sid=ebc6135c-345e-4640-b395-daff190a96e7 It’s a small change, but it makes the delete process safer and smoother.
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
@ -50,6 +50,13 @@ export const DeleteDocumentDialog = ({
|
||||
},
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setInputValue('');
|
||||
setIsDeleteEnabled(status === DocumentStatus.DRAFT);
|
||||
}
|
||||
}, [open, status]);
|
||||
|
||||
const onDelete = async () => {
|
||||
try {
|
||||
await deleteDocument({ id, status });
|
||||
|
||||
Reference in New Issue
Block a user