-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
fix: form attribute in button doesn't work and throws error #31506
Comments
@nicholasrice Any thoughts on the best approach for this? |
A bit of context on all of this here (I had to catch myself up on what this code myself): microsoft/fast#3534 (comment) I think your 1st option is the simplest and most in line with the current solution, though I don't follow the part about creating a form id and then removing it. If the form element doesn't have an id, I'd expect submission would just fail. I think it's enough to simply reflect the |
Disregard that part. I had a thought in my head as I was finishing the report and it wasn't fully fleshed out. Mapping the form |
@claviska If you are interested in contributing the fix, we'd love to have you take that on 😄 Let me know. |
I am interested in seeing this bug get fixed as, via the fluentui-blazor repo it is impacting me. How can I show my dependancy on this bug so it can be prioritised to be fixed in the future? |
Transferring this issue as I believe the dependency in fluentui-blazor is now on the fluentui web components. |
Closing this as resolved with #30999 in Beta (though I believe it was also resolved earlier) |
🐛 Bug Report
The documented
form
attribute on FAST Button is intended to mimic that of a native<button>
by allowing the user to pass a form id, effectively reassigning its form owner.This doesn't work in any browser I tested, and in Chromium results in the following error:
Additionally, it appears as though other form-related attributes including
formaction
,formmethod
,formtarget
, etc. do not have any effect in any browser.💻 Repro or Code Sample
https://jsfiddle.net/d690np3s/1/
🤔 Expected Behavior
In the repro above, the form should be submitted when the button is activated. The form should submit using a GET request to
/get
in a new tab/window.😯 Current Behavior
Nothing happens and the aforementioned error is thrown.
💁 Possible Solution
I believe this is happening because the call to
requestSubmit()
is passing the proxy, but the proxy isn't understood to be "owned" by the form.I know of two quick ways to solve this:
form
attribute to the proxy, e.g.this.proxy.setAttribute("form", this.form.id)
.This appears to work fine, but relies on the form having an id. Otherwise, the fix will need to account for that by creating a unique id, linking it, and removing it after submission.requestSubmit()
, e.g.this.form.append(proxy)
, and restore its position as a child of the host element after submission.However, an even better solution may be to rework the proxy logic so it's aware of linked forms and attaches the proxy to the form instead of the host element when a
form
attribute exists.I'm happy to commit some of my team's bandwidth to this if we can get confirmation of the preferred solution.
The text was updated successfully, but these errors were encountered: