Commit d57f232 1 parent 36ae140 commit d57f232 Copy full SHA for d57f232
File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -120,4 +120,11 @@ impl ButtonRef {
120
120
_ = button_el. click ( ) ;
121
121
}
122
122
}
123
+
124
+ /// Focus the button element.
125
+ pub fn focus ( & self ) {
126
+ if let Some ( button_el) = self . button_ref . get_untracked ( ) {
127
+ _ = button_el. focus ( ) ;
128
+ }
129
+ }
123
130
}
Original file line number Diff line number Diff line change @@ -209,9 +209,14 @@ let click = move |_| {
209
209
button_ref . get_untracked (). unwrap (). click ()
210
210
};
211
211
212
+ let focus = move | _ | {
213
+ button_ref . get_untracked (). unwrap (). focus ()
214
+ };
215
+
212
216
view! {
213
217
<Space >
214
218
<Button on_click = click >" Click" </ Button >
219
+ <Button on_click = focus >" Focus" </ Button >
215
220
<Button comp_ref = button_ref on_click >{count }</ Button >
216
221
</ Space >
217
222
}
@@ -244,6 +249,7 @@ view! {
244
249
245
250
### ButtonRef Props
246
251
247
- | Name | Type | Description |
248
- | ----- | ----------- | ------------------------ |
252
+ | Name | Type | Description |
253
+ | ----- | ----------- | ------------------------- |
249
254
| click | ` Fn(&self) ` | Click the button element. |
255
+ | focus | ` Fn(&self) ` | Focus the button element. |
You can’t perform that action at this time.
0 commit comments