Clear selection state when exiting select mode (#161267)
Fixes https://github.com/flutter/devtools/issues/8654
This commit is contained in:
parent
4b23b81828
commit
322f7af5fb
@ -1090,7 +1090,7 @@ mixin WidgetInspectorService {
|
||||
getter: () async => WidgetsBinding.instance.debugShowWidgetInspectorOverride,
|
||||
setter: (bool value) {
|
||||
if (WidgetsBinding.instance.debugShowWidgetInspectorOverride != value) {
|
||||
WidgetsBinding.instance.debugShowWidgetInspectorOverride = value;
|
||||
_changeWidgetSelectionMode(value, notifyStateChange: false);
|
||||
}
|
||||
return Future<void>.value();
|
||||
},
|
||||
@ -1633,10 +1633,16 @@ mixin WidgetInspectorService {
|
||||
}
|
||||
|
||||
/// Changes whether widget selection mode is [enabled].
|
||||
void _changeWidgetSelectionMode(bool enabled) {
|
||||
void _changeWidgetSelectionMode(bool enabled, {bool notifyStateChange = true}) {
|
||||
WidgetsBinding.instance.debugShowWidgetInspectorOverride = enabled;
|
||||
if (notifyStateChange) {
|
||||
_postExtensionStateChangedEvent(WidgetInspectorServiceExtensions.show.name, enabled);
|
||||
}
|
||||
if (!enabled) {
|
||||
// If turning off selection mode, clear the current selection.
|
||||
selection.currentElement = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a DevTools uri linking to a specific element on the inspector page.
|
||||
String? _devToolsInspectorUriForElement(Element element) {
|
||||
@ -3056,7 +3062,7 @@ class InspectorSelection with ChangeNotifier {
|
||||
}
|
||||
if (currentElement != element) {
|
||||
_currentElement = element;
|
||||
_current = element!.findRenderObject();
|
||||
_current = element?.findRenderObject();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
@ -502,15 +502,8 @@ class _TestWidgetInspectorService extends TestWidgetInspectorService {
|
||||
await tester.tap(find.byKey(exitWidgetSelectionButtonKey));
|
||||
await tester.pump();
|
||||
|
||||
// Tap on the top button and verify it is not selected in the Inspector.
|
||||
await tester.tap(find.text('TOP'));
|
||||
expect(log, equals(<String>['top']));
|
||||
|
||||
// Ensure the inspector selection is still BOTTOM (not TOP).
|
||||
expect(
|
||||
paragraphText(WidgetInspectorService.instance.selection.current! as RenderParagraph),
|
||||
equals('BOTTOM'),
|
||||
);
|
||||
// Ensure the inspector selection is now cleared.
|
||||
expect(WidgetInspectorService.instance.selection.current, isNull);
|
||||
});
|
||||
|
||||
testWidgets('WidgetInspector non-invertible transform regression test', (
|
||||
|
Loading…
x
Reference in New Issue
Block a user