Skip to content

Commit

Permalink
fix: problem that dialog remember its state when closed (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
name committed Dec 14, 2022
1 parent a2c4a6f commit 65e9cfe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
12 changes: 10 additions & 2 deletions frontend/components/CreateChannelDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,16 @@ export default function CreateChannelDialog({ open, onClose, onSubmit }) {
onClose();
}

function close() {
setName('');
setDescription('');
setPassword('');
setIsPrivate(false);
onClose();
}

return (
<Dialog open={open} onClose={onClose} fullWidth>
<Dialog open={open} onClose={close} fullWidth>
<DialogTitle>Create new channel</DialogTitle>
<DialogContent>
<TextField
Expand Down Expand Up @@ -69,7 +77,7 @@ export default function CreateChannelDialog({ open, onClose, onSubmit }) {
/>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>Cancel</Button>
<Button onClick={close}>Cancel</Button>
<Button onClick={submit}>Create</Button>
</DialogActions>
</Dialog>
Expand Down
9 changes: 7 additions & 2 deletions frontend/components/PasswordDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import { useState } from 'react';
export default function PasswordDialog({ open, onClose, onSubmit }) {
const [password, setPassword] = useState('');

function close() {
setPassword('');
onClose();
}

return (
<Dialog open={open} onClose={onClose}>
<Dialog open={open} onClose={close}>
<DialogTitle>
Enter password
</DialogTitle>
Expand All @@ -25,7 +30,7 @@ export default function PasswordDialog({ open, onClose, onSubmit }) {
/>
</DialogContent>
<DialogActions>
<Button onClick={onClose}>Cancel</Button>
<Button onClick={close}>Cancel</Button>
<Button onClick={() => onSubmit(password)}>Enter</Button>
</DialogActions>
</Dialog>
Expand Down

0 comments on commit 65e9cfe

Please sign in to comment.