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

Replace data grid column headers with custom template #5266

Merged

Conversation

adamint
Copy link
Member

@adamint adamint commented Aug 12, 2024

Description

@vnbaaij graciously added the ability to resize columns via a UI to fluentui-blazor. However, this is done by adding a button to the column header cell, space which adds up when there are many columns in a grid. For example,
image

We are still required to have some way to toggle this UI, so I created two wrapper classes FluentTemplateColumn and FluentPropertyColumn which set the header cell template to a button that, when clicked, opens a menu allowing the user to select between Sort and Resize - this UI concept is taken directly from the accessible data grid example provided here. The button is not a MenuButton because we do not want to show the chevron (again, for space reasons).

The resize ui (column options ui) is toggled if a cell is clicked that is not sortable, as can be seen in the recording below. Most changes are Property/TemplateColumn -> AspireProperty/TemplateColumn

Screen.Recording.2024-08-12.at.11.28.47.AM.mov

Fixes #3364, fixes #3365

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?
    • Yes
      • Link to aspire-docs issue:
    • No

@vnbaaij
Copy link
Contributor

vnbaaij commented Aug 12, 2024

@dvoituron should we perhaps consider this to be our default behavior as well?

@JamesNK
Copy link
Member

JamesNK commented Aug 13, 2024

The context menu sometimes appears on the right of the column instead of the left:

context-menu-position

@JamesNK
Copy link
Member

JamesNK commented Aug 13, 2024

The curved arrow button feels confusing. It seems to be a reset button, yes?

image

Should it only be enabled when there is a value to reset? Otherwise, people will click on it and not see any change. Also, clicking the tick button closes the popup. I think that clicking the reset button should close the dialog as well.


Edit: I think this feedback can be ignored if we go with +/- buttons. See below.

@JamesNK
Copy link
Member

JamesNK commented Aug 13, 2024

I'm curious if there was a reason why you chose a text box compared to + and - buttons like FluentUI?

image

https://www.fluentui-blazor.net/DataGrid

It is easier to find the size you want by tapping those buttons compared to guessing with a pixel number.

@JamesNK
Copy link
Member

JamesNK commented Aug 13, 2024

Discussion here indicates +/- are ok.

@typeparam TItem
@inject IStringLocalizer<ControlsStrings> Loc

<FluentDataGrid Items="@Items"
<FluentDataGrid ResizeLabel="@AspireFluentDataGridHeaderCell.GetResizeLabel(Loc)"
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I think there might be the opportunity to reduce the amount of change by having a custom FluentDataGrid type instead of custom columns. The custom grid type could loop through the columns and set HeaderCellItemTemplate = AspireFluentDataGridHeaderCell.RenderHeaderContent(Grid); on all the columns.

However, that might create problems of its own if there are situations where that is wrong behavior. Custom columns that set the header is probably ok for now. It's verbose, but it gives us control.

@vnbaaij
Copy link
Contributor

vnbaaij commented Aug 13, 2024

The curved arrow button feels confusing. It seems to be a reset button, yes?

image

Should it only be enabled when there is a value to reset? Otherwise, people will click on it and not see any change. Also, clicking the tick button closes the popup. I think that clicking the reset button should close the dialog as well.


Edit: I think this feedback can be ignored if we go with +/- buttons. See below.

Yes, it is a reset button (same as Shift+r key).
I don't think we have a mechanism yet to determine if any changes have been made.
Agree on reset closing the dialog.

@vnbaaij
Copy link
Contributor

vnbaaij commented Aug 13, 2024

I'm curious if there was a reason why you chose a text box compared to + and - buttons like FluentUI?

image

https://www.fluentui-blazor.net/DataGrid

It is easier to find the size you want by tapping those buttons compared to guessing with a pixel number.

We offer both as options for resizing. It is controlled by the ResizeType parameter

@dvoituron
Copy link
Contributor

@dvoituron should we perhaps consider this to be our default behavior as well?

Yes, I find it preferable to have a minimum of visual information on the grid headers.
And it will look more like FluentUI React.

…gle-pointer

# Conflicts:
#	src/Aspire.Dashboard/Components/Pages/Traces.razor
@adamint
Copy link
Member Author

adamint commented Aug 14, 2024

I'm curious if there was a reason why you chose a text box compared to + and - buttons like FluentUI?

https://www.fluentui-blazor.net/DataGrid

It is easier to find the size you want by tapping those buttons compared to guessing with a pixel number.

Should it only be enabled when there is a value to reset? Otherwise, people will click on it and not see any change. Also, clicking the tick button closes the popup. I think that clicking the reset button should close the dialog as well.

We don't own that resize UI. That's provided from fluentui-blazor. I changed it to Discrete, but @vnbaaij should we just open issues for the display of that UI?

@adamint
Copy link
Member Author

adamint commented Aug 14, 2024

The context menu sometimes appears on the right of the column instead of the left:

context-menu-position context-menu-position

I couldn't see how that behavior is anything but a bug in fluentui. I've been trying to figure it out, even setting the horizontal position explicitly to left or start doesn't change it. @vnbaaij for confirmation

However, if there's no easy resolution, since this isn't a blocking bug - whereas we are on strict timelines for accessibility sev2s - we could still merge.

@JamesNK
Copy link
Member

JamesNK commented Aug 15, 2024

Agree that it's not a blocking bug. But please create an issue in the fluentui repo.

# Conflicts:
#	src/Aspire.Dashboard/Components/Pages/Metrics.razor
@adamint adamint enabled auto-merge (squash) August 15, 2024 15:15
@adamint
Copy link
Member Author

adamint commented Aug 15, 2024

/azp run

1 similar comment
@adamint
Copy link
Member Author

adamint commented Aug 15, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@adamint
Copy link
Member Author

adamint commented Aug 16, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@drewnoakes
Copy link
Member

drewnoakes commented Aug 16, 2024

Build failed with a timeout of 100 seconds on downloading a file:

##[error].packages/microsoft.net.runtime.workloadtesting.internal/9.0.0-preview.5.24272.3/Sdk/WorkloadTesting.Core.targets(82,5): error MSB3923: (NETCORE_ENGINEERING_TELEMETRY=Build) Failed to download file "https://dot.net/v1/dotnet-install.sh". The request was canceled due to the configured HttpClient.Timeout of 100 seconds elapsing. ---> A task was canceled. ---> A task was canceled.

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@adamint adamint merged commit 37261ec into dotnet:main Aug 16, 2024
11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
5 participants