Skip to content

Commit f35bec8

Browse files
lisaelBruno Dupuisxarvic
authored
Fix focus on hidden widget in Either (#1860)
* 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]>
1 parent 177f3d6 commit f35bec8

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ Garrett Risley
1515
Robert Wittams
1616
Jaap Aarts
1717
Maximilian Köstler
18+
Bruno Dupuis

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ You can find its changes [documented below](#070---2021-01-01).
8484
- X11 backend now supports scaling([#1751] by [@Maan2003])
8585
- X11 backend now supports changing cursors ([#1755] by [@Maan2003])
8686
- X11 backend now uses the platform locale ([#1756] by [@Maan2003])
87+
- `Either` and `Tab` widgets were still propagating events to hidden widgets ([#1860] by [@lisael])
8788

8889
### Visual
8990

@@ -493,6 +494,7 @@ Last release without a changelog :(
493494
[@r-ml]: https://github.com/r-ml
494495
[@djeedai]: https://github.com/djeedai
495496
[@bjorn]: https://github.com/bjorn
497+
[@lisael]: https://github.com/lisael
496498

497499
[#599]: https://github.com/linebender/druid/pull/599
498500
[#611]: https://github.com/linebender/druid/pull/611
@@ -744,6 +746,7 @@ Last release without a changelog :(
744746
[#1825]: https://github.com/linebender/druid/pull/1825
745747
[#1843]: https://github.com/linebender/druid/pull/1843
746748
[#1851]: https://github.com/linebender/druid/pull/1851
749+
[#1860]: https://github.com/linebender/druid/pull/1860
747750
[#1861]: https://github.com/linebender/druid/pull/1861
748751
[#1863]: https://github.com/linebender/druid/pull/1863
749752

druid/src/widget/either.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<T: Data> Widget<T> for Either<T> {
7575
let current = (self.closure)(data, env);
7676
if current != self.current {
7777
self.current = current;
78-
ctx.request_layout();
78+
ctx.children_changed();
7979
}
8080
self.current_widget().update(ctx, data, env)
8181
}

druid/src/widget/tabs.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabBar<TP> {
374374
if let LifeCycle::WidgetAdded = event {
375375
self.ensure_tabs(data);
376376
ctx.children_changed();
377-
ctx.request_layout();
378377
}
379378

380379
for (_, tab) in self.tabs.iter_mut() {
@@ -397,7 +396,6 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabBar<TP> {
397396
if data.policy.tabs_changed(&old_data.inner, &data.inner) {
398397
self.ensure_tabs(data);
399398
ctx.children_changed();
400-
ctx.request_layout();
401399
} else if old_data.selected != data.selected {
402400
ctx.request_paint();
403401
}
@@ -611,7 +609,6 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabsBody<TP> {
611609
if let LifeCycle::WidgetAdded = event {
612610
self.make_tabs(data);
613611
ctx.children_changed();
614-
ctx.request_layout();
615612
}
616613

617614
if event.should_propagate_to_hidden() {
@@ -638,7 +635,6 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabsBody<TP> {
638635
) {
639636
let init = if data.policy.tabs_changed(&old_data.inner, &data.inner) {
640637
ctx.children_changed();
641-
ctx.request_layout();
642638
Some(self.make_tabs(data))
643639
} else {
644640
None
@@ -648,7 +644,7 @@ impl<TP: TabsPolicy> Widget<TabsState<TP>> for TabsBody<TP> {
648644
self.transition_state = self
649645
.transition
650646
.tab_changed(old_data.selected, data.selected);
651-
ctx.request_layout();
647+
ctx.children_changed();
652648

653649
if self.transition_state.is_some() {
654650
ctx.request_anim_frame();

0 commit comments

Comments
 (0)