Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

TagHelper and non-TagHelper select tags in a form don't work well together. #3347

Closed
NTaylorMullen opened this issue Oct 19, 2015 · 4 comments
Assignees
Milestone

Comments

@NTaylorMullen
Copy link
Contributor

If you have:

<form asp-action="...">
    <select asp-for="...">
        ...
    </select>
    <select>
        <option value="...">...</option>
    </select>
</form>

The <option> tags in the second select will think that they're running under the first <select asp-for="...">. This can be fixed by transitioning the SelectTagHelper to properly use TagHelperContext.Items instead of relying on ViewContext.FormContext.FormData.

@Eilon Eilon added this to the 6.0.0-rc1 milestone Oct 20, 2015
@Eilon
Copy link
Member

Eilon commented Oct 20, 2015

Wow, call that OOPS!

@NTaylorMullen any idea if other tag helpers suffer from cross-talk like this?

@dougbu
Copy link
Member

dougbu commented Oct 20, 2015

@Eilon this is a to-do item we've had since we added the Items property bag -- which came after the <select> and <option> tag helpers. The problem is a corner case related to lifetime of the information relative to FormContext. And the new <form> tag helper for rendering at the end is the only other one that communicates to children but that one is definitely using the correct mechanism (FormContext). So, no chance of similar issues elsewhere.

@Eilon
Copy link
Member

Eilon commented Oct 20, 2015

@dougbu thanks, good to know.

NTaylorMullen added a commit that referenced this issue Oct 22, 2015
…ems`.

- Added functional tests to validate data created from a `SelectTagHelper` does not impact following `<select>` tags.

#3347
NTaylorMullen added a commit that referenced this issue Oct 22, 2015
…ems`.

- Added functional tests to validate data created from a `SelectTagHelper` does not impact following `<select>` tags.

#3347
NTaylorMullen added a commit that referenced this issue Oct 22, 2015
…ems`.

- Added functional tests to validate data created from a `SelectTagHelper` does not impact following `<select>` tags.
- Also moved the new `SelectTagHelper` communication flow into `TagHelper.Init`.

#3347
NTaylorMullen added a commit that referenced this issue Oct 23, 2015
…ems`.

- Added functional tests to validate data created from a `SelectTagHelper` does not impact following `<select>` tags.
- Also moved the new `SelectTagHelper` communication flow into `TagHelper.Init`.

#3347
@NTaylorMullen
Copy link
Contributor Author

911dfc5

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

No branches or pull requests

3 participants