Skip to content

Commit

Permalink
clear modal on close
Browse files Browse the repository at this point in the history
  • Loading branch information
zaknesler committed Jun 2, 2024
1 parent 1db05b9 commit 89dd1a6
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions ui/src/components/modals/create-feed-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Dialog } from '@kobalte/core/dialog';
import { useNavigate } from '@solidjs/router';
import { createMutation, useQueryClient } from '@tanstack/solid-query';
import { HiSolidXMark } from 'solid-icons/hi';
import { type Component, type Setter, Show, createSignal } from 'solid-js';
import { type Component, type Setter, Show, createEffect, createSignal } from 'solid-js';
import { getErrorMessage } from '~/api';
import { addFeed } from '~/api/feeds';
import { QUERY_KEYS } from '~/constants/query';
Expand Down Expand Up @@ -42,15 +42,24 @@ export const CreateFeedModal: Component<CreateFeedProps> = props => {
navigate(`/feeds/${feed.uuid}`);

props.setOpen(false);
add.reset();
setValue('');
};

const handleOpenAutoFocus = (event: Event) => {
event.preventDefault();
inputElement()?.focus();
};

// Reset form state on close
createEffect(() => {
if (props.open) return;

// Delay 150ms to let animation play out
setTimeout(() => {
add.reset();
setValue('');
}, 150);
});

return (
<Dialog open={props.open} onOpenChange={props.setOpen}>
<Dialog.Portal>
Expand Down

0 comments on commit 89dd1a6

Please sign in to comment.