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
DefaultCommand: Not working for button outside (but linked to) form #11814
Comments
BjornJaspers
added
‼️ needs-triage
Issue needs triaging
🐞 defect
Bug...Something isn't working
labels
Apr 25, 2024
Hmmm this is quite and odd use case. If you submit a PR we can review and discuss... |
melloware
added
discussion
Item needs to be discussed by core devs
and removed
‼️ needs-triage
Issue needs triaging
labels
Apr 25, 2024
BjornJaspers
added a commit
to BjornJaspers/primefaces
that referenced
this issue
May 5, 2024
…o allow using them in JavaScript code
BjornJaspers
added a commit
to BjornJaspers/primefaces
that referenced
this issue
May 5, 2024
…port submit buttons that are placed outside (but linked to) the form
Finally I found some time to create a PR with the fix I had in mind: #11878 |
BjornJaspers
added a commit
to BjornJaspers/primefaces
that referenced
this issue
May 14, 2024
…pport DefaultCommand usage
BjornJaspers
added a commit
to BjornJaspers/primefaces
that referenced
this issue
May 21, 2024
BjornJaspers
added a commit
to BjornJaspers/primefaces
that referenced
this issue
May 22, 2024
…o allow using them in JavaScript code
BjornJaspers
added a commit
to BjornJaspers/primefaces
that referenced
this issue
May 22, 2024
…port submit buttons that are placed outside (but linked to) the form
BjornJaspers
pushed a commit
to BjornJaspers/primefaces
that referenced
this issue
May 22, 2024
…pport DefaultCommand usage
melloware
pushed a commit
that referenced
this issue
May 22, 2024
…ed to) form (#11977) * Fix #11814: Add data-pf-form attribute to command buttons to allow using them in JavaScript code * Fix #11814: Look up form linked to the target button to support submit buttons that are placed outside (but linked to) the form * Fix #11814: Add data-pf-form attribute to CommandLink to support DefaultCommand usage --------- Co-authored-by: Bjorn Jaspers <Bjorn.Jaspers@cegeka.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The DefaultCommand component only works when it targets CommandButtons that are linked to (using the form-attribute), but placed outside the form. See reproducer.
I'm not entirely sure if this should be classified as a bug or not, but I thought it would make sense if this usage would be supported (it sure would help in my use-case).
I already looked through the code and noticed that it indeed doesn't take into account buttons that are not placed inside the form, it only takes into account the form that is actualy enclosed by the target button:
primefaces/primefaces/src/main/resources/META-INF/resources/primefaces/forms/forms.defaultcommand.js
Line 40 in 3c1945e
If possible I'd like to contribute with a fix for this!
Reproducer
In the reproducer I created a form with an InputText, CommandButton "Submit inside form" and DefaultCommand. Next to the form there's another CommandButton "Submit outside form" that is linked to the form using the form-attribute. I configured the DefaultCommand to point to button "Submit outside form", but when I press the Enter-key when my focus is in the InputText, the form is submitted using button "Submit inside form".
PrimeFaces_DefaultCommand_reproducer.zip
Relevant portion from reproducer:
Expected behavior
When pressing the enter key in the InputText, the form should be submitted by button "Submit outside form", as configured in the DefaultCommand component.
PrimeFaces edition
Community
PrimeFaces version
13.0.8
Theme
No response
JSF implementation
All
JSF version
2.3
Java version
17
Browser(s)
No response
The text was updated successfully, but these errors were encountered: