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

Fix text selection issues in the codeview and console #6099

Merged
merged 2 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ class _ConsoleOutputState extends State<_ConsoleOutput>
} else if (line is VariableConsoleLine) {
return ExpandableVariable(
variable: line.variable,
isSelectable: false,
);
} else {
assert(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ExpandableVariable extends StatelessWidget {
Key? key,
this.variable,
this.dataDisplayProvider,
this.isSelectable = true,
}) : super(key: key);

@visibleForTesting
Expand All @@ -25,6 +26,8 @@ class ExpandableVariable extends StatelessWidget {
final DartObjectNode? variable;
final Widget Function(DartObjectNode, void Function())? dataDisplayProvider;

final bool isSelectable;

@override
Widget build(BuildContext context) {
final variable = this.variable;
Expand All @@ -42,6 +45,7 @@ class ExpandableVariable extends StatelessWidget {
onTap: onPressed,
),
onItemSelected: onItemPressed,
isSelectable: isSelectable,
);
}

Expand Down
14 changes: 12 additions & 2 deletions packages/devtools_app/lib/src/shared/tree.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class TreeView<T extends TreeNode<T>> extends StatefulWidget {
this.emptyTreeViewBuilder,
this.scrollController,
this.includeScrollbar = false,
this.isSelectable = true,
});

final ValueListenable<List<T>> dataRootsListenable;
Expand All @@ -52,6 +53,8 @@ class TreeView<T extends TreeNode<T>> extends StatefulWidget {

final bool includeScrollbar;

final bool isSelectable;

@override
State<TreeView<T>> createState() => _TreeViewState<T>();
}
Expand All @@ -75,8 +78,8 @@ class _TreeViewState<T extends TreeNode<T>> extends State<TreeView<T>>
if (dataFlatList.isEmpty) return _emptyTreeViewBuilder();
final content = SizedBox(
height: dataFlatList.length * defaultTreeViewRowHeight,
child: SelectionArea(
child: ListView.builder(
child: _maybeWrapInSelectionArea(
ListView.builder(
itemCount: dataFlatList.length,
itemExtent: defaultTreeViewRowHeight,
physics: const ClampingScrollPhysics(),
Expand Down Expand Up @@ -111,6 +114,13 @@ class _TreeViewState<T extends TreeNode<T>> extends State<TreeView<T>>
return const SizedBox();
}

Widget _maybeWrapInSelectionArea(Widget tree) {
if (widget.isSelectable) {
return SelectionArea(child: tree);
}
return tree;
}

// TODO(kenz): animate expansions and collapses.
void _onItemSelected(T item) async {
// Order of execution matters for the below calls.
Expand Down