feat(editable cell): Add focus and blur handling for EditableCell suggestions
-Added on_focus and on_blur props to the EditableCell component to handle focus and blur events.
This commit is contained in:
parent
d81b2a285e
commit
e36a24b9d0
1 changed files with 8 additions and 0 deletions
|
@ -9,6 +9,8 @@ pub fn EditableCell(
|
|||
key: Arc<String>,
|
||||
focused_cell: ReadSignal<Option<String>>,
|
||||
set_focused_cell: WriteSignal<Option<String>>,
|
||||
on_focus: Option<Callback<()>>,
|
||||
on_blur: Option<Callback<()>>,
|
||||
) -> impl IntoView {
|
||||
let input_ref = create_node_ref::<html::Input>();
|
||||
let (local_value, set_local_value) = create_signal(value.clone());
|
||||
|
@ -33,6 +35,9 @@ pub fn EditableCell(
|
|||
move |_| {
|
||||
log!("Focus gained for key: {}", key);
|
||||
set_focused_cell.set(Some(key.to_string()));
|
||||
if let Some(on_focus) = &on_focus {
|
||||
on_focus.call(());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -40,6 +45,9 @@ pub fn EditableCell(
|
|||
log!("Focus lost");
|
||||
set_focused_cell.set(None);
|
||||
commit_input();
|
||||
if let Some(on_blur) = &on_blur {
|
||||
on_blur.call(());
|
||||
}
|
||||
};
|
||||
|
||||
// Update input field value when focused cell changes
|
||||
|
|
Loading…
Add table
Reference in a new issue