orbital_base_components/button/ref.rs
1use leptos::{html, prelude::*};
2
3#[derive(Clone)]
4pub struct ButtonRef {
5 pub(crate) button_ref: NodeRef<html::Button>,
6}
7
8impl ButtonRef {
9 /// Click the button element.
10 pub fn click(&self) {
11 if let Some(button_el) = self.button_ref.get_untracked() {
12 button_el.click();
13 }
14 }
15
16 /// Focus the button element.
17 pub fn focus(&self) {
18 if let Some(button_el) = self.button_ref.get_untracked() {
19 _ = button_el.focus();
20 }
21 }
22}