Fix bug for new plate modal

The close callback wasn't triggered when the
modal's onclose event fired.
This commit is contained in:
Emilia Allison 2023-06-06 18:45:24 -04:00
parent 5074b52369
commit 421d937037
Signed by: emilia
GPG Key ID: 7A3F8997BFE894E0
1 changed files with 8 additions and 1 deletions

View File

@ -60,6 +60,13 @@ pub fn NewPlateDialog(props: &NewPlateDialogProps) -> Html {
})
};
let onclose = {
let close_callback = props.close_callback.clone();
Callback::from(move |e: Event| {
close_callback.emit(());
})
};
// This whole section is optional, only if you want the backdrop
let dialog_ref = use_node_ref();
{
@ -78,7 +85,7 @@ pub fn NewPlateDialog(props: &NewPlateDialogProps) -> Html {
}
html! {
<dialog ref={dialog_ref} class="dialog new_plate_dialog">
<dialog ref={dialog_ref} class="dialog new_plate_dialog" onclose={onclose}>
<h2>{"Create a plate:"}</h2>
<form onsubmit={new_plate_callback}>
<input type="text" name="new_plate_name" placeholder="Name"/>