Skip to content

Pass through arbitrary attributes to QuickGrid #48268

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

Closed
wants to merge 12 commits into from

Conversation

ElderJames
Copy link
Contributor

Pass through arbitrary attributes to QuickGrid

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Summary of the changes (Less than 80 chars)

Add the AdditionalAttributes parameter with CaptureUnmatchedValues flag and pass through to QuickGrid table element.

Description

Follow up aspnet/AspLabs#559 (comment)

Fixes #45327

@ElderJames ElderJames requested a review from a team as a code owner May 17, 2023 03:56
@ghost ghost added area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member labels May 17, 2023
@ghost
Copy link

ghost commented May 17, 2023

Thanks for your PR, @ElderJames. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@SteveSandersonMS
Copy link
Member

Thanks @ElderJames! This is looking really good.

One small issue will arise with this implementation, though. The grid already generates a class attribute automatically adding both quickgrid and a loading class that toggles based on any associated ItemsProvider. The implementation here will overwrite that if the developer provides any class attribute, thereby breaking the "loading" indicator and other styles.

To solve this, I would suggest:

This would preserve existing behaviors while also letting the developer add extra classes using a normal class attribute.

@ElderJames
Copy link
Contributor Author

Thanks for your suggestions @SteveSandersonMS , I have fixed this. But I'm a little confused about the test and why the style won't be passed to the table.

@ghost
Copy link

ghost commented Jun 1, 2023

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no breaking changes are introduced, please leave an /azp run comment here to rerun the CI pipeline and confirm success before merging the change.

@ghost ghost added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Jun 1, 2023
@ElderJames
Copy link
Contributor Author

Hello @SteveSandersonMS , could you please teach me how to solve the style attribute issue?

Copy link
Member

@mkArtakMSFT mkArtakMSFT left a comment

Choose a reason for hiding this comment

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

Thanks for your PR.
Glad to see updated tests too. There is just one minor optimization I've left a comment about and then I think this will be in good shape to take.

Comment on lines 397 to 400
if (AdditionalAttributes?.TryGetValue("class", out var originalClass) == true)
{
gridClass += $" {originalClass}";
}
Copy link
Member

Choose a reason for hiding this comment

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

You can utilize the AttributeUtilities.CombineClassNames method instead:

public static string? CombineClassNames(IReadOnlyDictionary<string, object>? additionalAttributes, string? classNames)

Here is a usage example in the CssClass property of the InputBase type;

protected string CssClass

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @mkArtakMSFT , I have done the changes, but AttributeUtilities.CombineClassNames is internal that can't be accessed in QuickGrid library. How to solve that?

@SteveSandersonMS
Copy link
Member

Thanks for the update. This is now ready to merge, except for fixing the final compiler issue. We need it to go in today, so I've made the necessary change and am continuing the PR in #50051, so will close this PR in favour of that. The new PR still uses the original commits from here so hopefully @ElderJames will still be credited as the author.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components community-contribution Indicates that the PR has been added by a community member pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend Quickgrid with custom attributes such as 'style'
3 participants