Skip to content

Add unmatched attributes support to forms #10712

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

Merged
merged 3 commits into from
May 31, 2019
Merged

Add unmatched attributes support to forms #10712

merged 3 commits into from
May 31, 2019

Conversation

rynowak
Copy link
Member

@rynowak rynowak commented May 31, 2019

Part of #5071

This change makes it possible to use attributes that aren't directly supported by our components.

Ex:

<InputText @bind="person.Name" placeholder="Enter your name" />

placeholder isn't something we define or handle inside InputText - it just gets passed through to the underlying input element.

This support is limited to components implemented in C# for now, and we'll be doing a language feature to light it up for components written in Razor in preview 7 (see #5071)

I'm logging a separate issue to follow up on two things I didn't address in this PR because I think they need a discussion.

  • Should we remove Id and Class from these components now that we support pass through
  • Should we rewrite NavLink to use this feature

@rynowak rynowak requested a review from SteveSandersonMS as a code owner May 31, 2019 20:19
@rynowak rynowak requested review from javiercn and pranavkm May 31, 2019 20:19
Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

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

Looks good!

@rynowak rynowak merged commit 993d943 into master May 31, 2019
@ghost ghost deleted the rynowak/attributes branch May 31, 2019 21:50
@Eilon Eilon added the area-blazor Includes: Blazor, Razor Components label May 31, 2019
@SteveSandersonMS
Copy link
Member

I'm logging a separate issue to follow up on two things I didn't address in this PR because I think they need a discussion.

I didn't see the other issue but my opinions are:

Should we remove Id and Class from these components now that we support pass through

Yes

Should we rewrite NavLink to use this feature

Yes

builder.AddAttribute(3, "id", Id);
builder.AddAttribute(4, "class", CssClass);
builder.AddAttribute(5, "checked", BindMethods.GetValue(CurrentValue));
builder.AddAttribute(6, "onchange", BindMethods.SetValueHandler(__value => CurrentValue = __value, CurrentValue));
Copy link
Member

Choose a reason for hiding this comment

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

At some point, we should think about somehow combining any explicitly-provided onchange with the one that bind is using (e.g., calling theirs from ours).

@SteveSandersonMS
Copy link
Member

This is such a big improvement!

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants