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

Hierarchical TreeDataGrid expanded rows selection bug #17879

Open
VMMachal opened this issue Jan 3, 2025 · 2 comments
Open

Hierarchical TreeDataGrid expanded rows selection bug #17879

VMMachal opened this issue Jan 3, 2025 · 2 comments
Labels

Comments

@VMMachal
Copy link

VMMachal commented Jan 3, 2025

Describe the bug

When opening couple of first level node rows of a hierarchical tree data grid that contains multiple levels of other children nodes and the whole grid has only one columns (like a fake TreeView), the first level rows in between the already expanded other rows can't be selected and the top one is selected instead.
For example, if I expand first level rows from 1 to 5, they are easily selectable by the expandable arrow. But if I click anywhere else e.g. a Stack panel that defines the layout of each row, the row 2 or 3 or 4 can't be selected.

To Reproduce

Create Hierarchical data grid with at least 10 rows, only 1 column and multiple levels of children nodes. This data grid must be created as below:

        var source = new HierarchicalTreeDataGridSource<IGridLayerNode>(GridLayerNodes)
        {
            Columns =
            {
                new HierarchicalExpanderColumn<IGridLayerNode>(
                    new TemplateColumn<IGridLayerNode>(
                        "Name",
                        "FileNameCell",
                        null,
                        new GridLength(1, GridUnitType.Star)),
                    x => x.Nodes)
            }
        };

        source.RowSelection!.SingleSelect = false;
        Source = source;
        Source.Selection = new TreeDataGridCellSelectionModel<IGridLayerNode>(source) { SingleSelect = false };

XAML:

	<TreeDataGrid Source="{Binding Source}" AutoDragDropRows="True" RowDragStarted="DragDrop_RowDragStarted"
                  RowDragOver="DragDrop_RowDragOver" Name="GridTree" Focusable="True">
		<TreeDataGrid.Resources>
			<DataTemplate x:Key="FileNameCell" DataType="layers:GridLayerNode">
				<Grid Background="Transparent">
					<views:GridLayerNodeView/>
				</Grid>
			</DataTemplate>
		</TreeDataGrid.Resources>
	</TreeDataGrid>

Then click on first 5 main layers nodes to unfold them with their children....then try to click for example 2nd or 3rd main layer. It will selected first layer or children of first layer instead. Seems like some hidden collision bug.

Expected behavior

When all main layer rows are expanded with their children, I should be able to easily selected any main layer row.

Avalonia version

11.2

OS

Windows

Additional context

No response

@VMMachal VMMachal added the bug label Jan 3, 2025
@VMMachal
Copy link
Author

VMMachal commented Jan 6, 2025

Also want to add that it happens in the nested children too.
For example. Fully expand first main node(about 5 levels of nested children nodes), then when I go back collapsing each level, at level 1 (meaning children of the main node), I can only select first child. Clicking on other children will select some other lower main nodes.
Test it with 10s or 100s of nodes, not just 1 child under each node.

@VMMachal
Copy link
Author

VMMachal commented Jan 8, 2025

I've found out that the root of the cause is the line from the Source creation
'Source.Selection = new TreeDataGridCellSelectionModel(source) { SingleSelect = false };'

this however is necessary in order to have a track for 'SelectedNode' where 'SelectionChanged' is triggered if you change a row.
Removing that code makes the selection fine, however the SelectionChanged event stops working.

I'm not sure if that selection is working as intended but that looks definitely like a bug.

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

No branches or pull requests

1 participant