Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger panel text selection improvements #6020

Merged
merged 10 commits into from
Jul 12, 2023

Conversation

elliette
Copy link
Member

@elliette elliette commented Jul 11, 2023

Fixes #6019
Work towards #5963

Note: Includes TODOS for #6018, which requires flutter/flutter#129692 to be fixed first

Demos (after):

NATIVE - codeview 2

NATIVE - vars

NATIVE - console

Demos (before):

selecting codeview before

selecting inspect before

selecting before console

@elliette elliette requested a review from a team as a code owner July 11, 2023 21:31
@elliette elliette requested review from CoderDake and removed request for a team July 11, 2023 21:31
// browser's native context menu on secondary-click, and instead use the
// menu provided by Flutter:
if (kIsWeb) {
unawaited(BrowserContextMenu.enableContextMenu());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really want to do this at the app-wide level? Will this break any flutter context menu actions we use elsewhere? Perhaps we could enable this menu more local to the console / debugger.

Copy link
Member Author

@elliette elliette Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this is a no-op (the context menu is already globally enabled) - what we really want to do is disable it, but currently are blocked by flutter/flutter#129692. I can switch this to disabling and just comment it out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about disabling the context menu closer to the source of where we have actually implemented our own context menus? Like in this example how the browser context menu is disabled and reenabled within the lifecycle of this widget: https://github.com/flutter/flutter/blob/e12167d98c44ad1977934399757a4351821f4f95/examples/api/lib/material/context_menu/context_menu_controller.0.dart#L34-L50

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered doing that, though I'm not sure where the best place would be. Would we want it on the entire debugger panel (and if so, would it be weird that that one panel has different context menus then the rest of DevTools)? Or on each selectable text region (which could get us into a weird state, eg context menu is disabled when codeview inits its state, then when the variable tree inits its state, then the variable tree is removed and the context menu is enabled, even though we still want it for codeview)?

I think we probably want the Flutter context menus everywhere. This matches the behavior for macos, and so ideally means the experience during development matches the experience in release-mode.

@@ -75,10 +53,10 @@ class DisplayProvider extends StatelessWidget {
}

final hasName = variable.name?.isNotEmpty ?? false;
return DevToolsTooltip(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason we removed the tooltip here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this was initially branched off of #6001 (which hasn't been submitted yet)

Comment on lines 88 to 116
final menuButtons = <ContextMenuButtonItem>[];
if (variable.isRerootable) {
menuButtons.add(
ContextMenuButtonItem(
onPressed: () {
ContextMenuController.removeAny();
final ref = variable.ref;
serviceManager.consoleService.appendBrowsableInstance(
instanceRef: variable.value as InstanceRef?,
isolateRef: ref?.isolateRef,
heapSelection: ref?.heapSelection,
);
},
label: 'Reroot',
),
);
}
if (serviceManager.inspectorService != null && variable.isRoot) {
menuButtons.add(
ContextMenuButtonItem(
onPressed: () {
ContextMenuController.removeAny();
_handleInspect(context);
},
label: 'Inspect',
),
);
}
return menuButtons;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be condensed:

return [
  if (variable.isRerootable)
    // reroot button
  if (serviceManager.inspectorService != null && variable.isRoot)
    // inspect button
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text selection in debugger panel is poor user experience
2 participants