Skip to content

Commit

Permalink
close #357 (#358)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerhat authored Jan 3, 2025
1 parent 2c3eee4 commit cd36205
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions thaw/src/input/docs/mod.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ let blur = move |_| {
input_ref.get_untracked().unwrap().blur()
};

let select = move |_| {
input_ref.get_untracked().unwrap().select()
};

view! {
<Space vertical=true>
<Space>
Expand All @@ -89,6 +93,9 @@ view! {
<Button on_click=blur>
"Blur"
</Button>
<Button on_click=select>
"Select"
</Button>
</Space>
<Input value comp_ref=input_ref/>
</Space>
Expand Down Expand Up @@ -155,3 +162,4 @@ view! {
| ----- | ----------- | ------------------------ |
| focus | `Fn(&self)` | Focus the input element. |
| blur | `Fn(&self)` | Blur the input element. |
| select | `Fn(&self)` | Select the input element. |
7 changes: 7 additions & 0 deletions thaw/src/input/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ impl InputRef {
_ = input_el.blur();
}
}

/// Select the input element.
pub fn select(&self) {
if let Some(input_el) = self.input_ref.get_untracked() {
_ = input_el.select();
}
}
}

#[derive(Debug, Default, PartialEq, Clone, Copy)]
Expand Down

0 comments on commit cd36205

Please sign in to comment.