Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

Fix nth child selector in data grid header

Open appel1 opened this issue 10 months ago • 13 comments

What does the pull request do?

Attempt at getting nth child selectors to work with data grid column headers.

What is the current behavior?

If you add or remove columns :nth-child and :nth-last-child applies to the wrong element.

What is the updated/expected behavior with this PR?

That nth-child and nth-last-child applies to the expected elements after adding or removing columns.

Fixed issues

Fixes #14695

appel1 avatar Apr 23 '24 15:04 appel1

@appel1 for debugging, you can also use src/Samples/Sandbox. You may need to add a reference to DataGrid project. Just fyi.

timunie avatar Apr 23 '24 15:04 timunie

You can test this PR using the following package version. 11.2.999-cibuild0047602-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

avaloniaui-bot avatar Apr 23 '24 15:04 avaloniaui-bot

@timunie Thanks for that, made things easier.

But why was the PR closed when I added another commit to it?

appel1 avatar Apr 23 '24 21:04 appel1

Not sure if this is the correct approach, but as far as I can tell it works after these changes.

appel1 avatar Apr 23 '24 21:04 appel1

You can test this PR using the following package version. 11.2.999-cibuild0047608-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

avaloniaui-bot avatar Apr 23 '24 21:04 avaloniaui-bot

You can test this PR using the following package version. 11.2.999-cibuild0047630-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

avaloniaui-bot avatar Apr 24 '24 07:04 avaloniaui-bot

Realized that taking visibility might be a bad idea. If you change visibility in the selector for example.

I'll check how this is handled elsewhere in Avalonia and update the PR.

I think nth child in CSS counts elements even if they are hidden.

appel1 avatar Apr 24 '24 22:04 appel1

Yes, nth child does count elements if they are hidden. The same goes with avalonia nth child, IIRC.

maxkatz6 avatar Apr 24 '24 23:04 maxkatz6

What about the hidden DataGridFillerColumn? Should that also be taken into account? So that nth-last-child(1) matches the filler column.

appel1 avatar Apr 25 '24 08:04 appel1

@cla-avalonia recheck

jmacato avatar Apr 25 '24 14:04 jmacato

  • [x] All contributors have signed the CLA.

cla-avalonia avatar Apr 25 '24 14:04 cla-avalonia

You can test this PR using the following package version. 11.2.999-cibuild0047774-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

avaloniaui-bot avatar Apr 26 '24 09:04 avaloniaui-bot

@cla-avalonia agree

appel1 avatar Apr 26 '24 10:04 appel1