Skip to content

Commit 0697483

Browse files
committed
fix(table): filter the table
1 parent d5a5482 commit 0697483

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/widget/input.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ impl Widget for Text {
5757
};
5858

5959
match key {
60-
exit_keys!() => return Ok(Broadcast::Exited),
60+
exit_keys!() => {
61+
self.content.try_borrow_mut()?.take();
62+
63+
return Ok(Broadcast::Exited);
64+
}
6165
Keypress::Printable(x) => {
6266
self.content
6367
.try_borrow_mut()?
@@ -128,4 +132,11 @@ impl Widget for Text {
128132

129133
Ok(())
130134
}
135+
136+
fn placement(&self) -> super::Placement {
137+
super::Placement {
138+
vertical: super::Constraint::Length(3),
139+
..Default::default()
140+
}
141+
}
131142
}

src/widget/table.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,13 @@ impl Widget for Filtered {
258258
if let Some(Keypress::Printable('/')) = event.key() {
259259
TABLE_FILTER.inc();
260260

261-
self.view
262-
.push(Text::builder().title("Filter").build().boxed());
261+
self.view.push(
262+
Text::builder()
263+
.title("Filter")
264+
.content(self.filter.clone())
265+
.build()
266+
.boxed(),
267+
);
263268

264269
return Ok(Broadcast::Consumed);
265270
}

0 commit comments

Comments
 (0)