Skip to content

Commit

Permalink
Fix focus on hidden widget in Either (#1860)
Browse files Browse the repository at this point in the history
* Fix focus on hidden widget in Either

* udpate CHANGELOG and AUTHORS

* Fix (?) hidden widget focus bug in Tab

I couldn't reproduce the bug in the example as the tab bar steals the focus anyway when we click on a tab

Whatever, it's still cleaner.

I also removed spurious ctx.request_layout calls, as it's already called in ctx.children_changed

* update the changelog

Co-authored-by: Bruno Dupuis <[email protected]>
Co-authored-by: Christoph <[email protected]>
  • Loading branch information
3 people authored Jul 9, 2021
1 parent 177f3d6 commit f35bec8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ Garrett Risley
Robert Wittams
Jaap Aarts
Maximilian Köstler
Bruno Dupuis
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ You can find its changes [documented below](#070---2021-01-01).
- X11 backend now supports scaling([#1751] by [@Maan2003])
- X11 backend now supports changing cursors ([#1755] by [@Maan2003])
- X11 backend now uses the platform locale ([#1756] by [@Maan2003])
- `Either` and `Tab` widgets were still propagating events to hidden widgets ([#1860] by [@lisael])

### Visual

Expand Down Expand Up @@ -493,6 +494,7 @@ Last release without a changelog :(
[@r-ml]: https://github.com/r-ml
[@djeedai]: https://github.com/djeedai
[@bjorn]: https://github.com/bjorn
[@lisael]: https://github.com/lisael

[#599]: https://github.com/linebender/druid/pull/599
[#611]: https://github.com/linebender/druid/pull/611
Expand Down Expand Up @@ -744,6 +746,7 @@ Last release without a changelog :(
[#1825]: https://github.com/linebender/druid/pull/1825
[#1843]: https://github.com/linebender/druid/pull/1843
[#1851]: https://github.com/linebender/druid/pull/1851
[#1860]: https://github.com/linebender/druid/pull/1860
[#1861]: https://github.com/linebender/druid/pull/1861
[#1863]: https://github.com/linebender/druid/pull/1863

Expand Down
2 changes: 1 addition & 1 deletion druid/src/widget/either.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl<T: Data> Widget<T> for Either<T> {
let current = (self.closure)(data, env);
if current != self.current {
self.current = current;
ctx.request_layout();
ctx.children_changed();
}
self.current_widget().update(ctx, data, env)
}
Expand Down
6 changes: 1 addition & 5 deletions druid/src/widget/tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabBar<TP> {
if let LifeCycle::WidgetAdded = event {
self.ensure_tabs(data);
ctx.children_changed();
ctx.request_layout();
}

for (_, tab) in self.tabs.iter_mut() {
Expand All @@ -397,7 +396,6 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabBar<TP> {
if data.policy.tabs_changed(&old_data.inner, &data.inner) {
self.ensure_tabs(data);
ctx.children_changed();
ctx.request_layout();
} else if old_data.selected != data.selected {
ctx.request_paint();
}
Expand Down Expand Up @@ -611,7 +609,6 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabsBody<TP> {
if let LifeCycle::WidgetAdded = event {
self.make_tabs(data);
ctx.children_changed();
ctx.request_layout();
}

if event.should_propagate_to_hidden() {
Expand All @@ -638,7 +635,6 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabsBody<TP> {
) {
let init = if data.policy.tabs_changed(&old_data.inner, &data.inner) {
ctx.children_changed();
ctx.request_layout();
Some(self.make_tabs(data))
} else {
None
Expand All @@ -648,7 +644,7 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabsBody<TP> {
self.transition_state = self
.transition
.tab_changed(old_data.selected, data.selected);
ctx.request_layout();
ctx.children_changed();

if self.transition_state.is_some() {
ctx.request_anim_frame();
Expand Down

0 comments on commit f35bec8

Please sign in to comment.