Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 Apr 2012 at 02:40 UTC
Updated:
14 Jul 2021 at 18:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
bcn commentedStatus change since there is a patch to review.
Comment #2
dawehnerWhat is the difference between button in input, or why do you need this feature?
Comment #3
bcn commentedThe general difference is a button can have html inside.
<button><h1>Click</h1></button>instead of:
<input type="button" />--http://stackoverflow.com/questions/469059/button-vs-input-type-button-which-to-use
I needed this because I was using a theme which used a element in the exposed filter of a view.
Comment #4
natted commentedI've tested this patch and use it also for the same reason as poster #3
Comment #5
juliakoelsch commentedI also tested it, because I ran into the issue described. Fixes issue for me as well.
Comment #6
zmove commented+1 for this, especially with the HTML5 that is coming a support is very important.
Comment #7
cpliakas commented+1, and I also confirm that the patch fixes the issue I ran into as well. This seems to have multiple testers with positive experiences and no discernable drawbacks, so marking as RTBC.
Comment #8
jibus commented+1, confirm that the patch works for me. Thanks !
Comment #9
dnewkerk commented+1 also. Tested and confirmed this works perfectly. I ran into this issue when using the Twitter Bootstrap theme (which is HTML5-based), though it likely affects most/all of the various HTML5-based themes.
Comment #10
muka commented+1 same issue on bootstrap theme, works for me
Comment #11
Lucasljj commentedallow-buttons-to-trigger-ajax.patch queued for re-testing.
Comment #12
dawehnerGreat. Thanks for providing and testing the patch.
Committed to 7.x-3.x and marked as to be ported to 8.x
Comment #13
batabata commentedWELL,HELPsFUL
Comment #14
richmac commentedComment #15
richmac commentedThe attached patch has been tested against a view created in 8.x-dev.
Comment #16
alansaviolobo commentedreroll
Comment #17
damienmckennaDoes this patch need tests? It makes complete sense to me and still applies against HEAD. RTBC?
Comment #18
Lucasljj commentedComment #19
mikefyfer commented.
Comment #20
mikefyfer commentedJust to update this real quick, as it's still an issue. In a hurry, so no patch here, just the code.
as of Drupal 8.0.4
In core/modules/views/js/ajax_view.js - change
Comment #21
heykarthikwithure-roll
Comment #23
devert commentedThis patch no longer seems to be able to be applied to latest Drupal 8.1.8.
Comment #24
devert commentedRe-roll so patch will work on Drupal 8.1.8
Comment #25
devert commentedComment #27
nerdacus commentedApplied #24 to Drupal 8.2.1 and it works as promised.
Comment #28
dawehnerI think the steps forward would be to add some test coverage.
Comment #30
mvwensen commentedClosed duplicate: #2897276: Allow the attachment of AJAX exposed form behavior to a button of type submit
Comment #32
b_sharpe commentedRe-roll
Comment #33
droplet commentedIMO, we should make it new .class rather than tag[attr] if it's a feature request. and mark existing way @deprecated.
Comment #34
nst37 commentedAre there any plans to bring back reset button and make it work with AJAX?
Comment #36
seanbReroll for 8.5 and 8.6, applies to both.
Comment #37
Alexandre360 commentedthe patch is quite simple and probably have no drawback. Any plan to commit it soon ?
Comment #38
b_sharpe commentedWorks great, can see no way for this to cause issue/conflict
Comment #39
hongpong commented+1 looks good to me, this would help with certain things.
Comment #40
alexpottIn order to commit a bug fix we need an automated to test to prove that we've fixed the bug and ensure that we don't break it again in the future. For more information about writing tests in Drupal 8 see the following links:
Comment #41
mishac commentedPatch didn't apply for me on 8.6-rc2. rerolling.
Comment #43
grantkruger#41 worked for me on 8.6 after #36 stopped working. Thanks to you both.
Comment #44
henkholtrop commentedRedid the patch. Now on the 8.6.x branch.
Comment #45
henkholtrop commentedComment #46
sanderwindTested #44 and works.
Comment #47
alexpottSee #40 we still need automated test coverage. Also as a new feature we need to target the next minor release branch.
Comment #49
lendudeHere is a test for this, test_only file is also the interdiff.
Comment #51
idebr commentedThis should be short array syntax. Test looks good!
Comment #52
lendudeFixed #51
Comment #53
idebr commentedThe feedback in #40 has been addressed.
Comment #55
lendudeUnrelated fail
Comment #57
andypostbot flux
Comment #60
lendudeMedia lib fail
Comment #61
heykarthikwithu+1 RTBC
Comment #62
lauriiiIs there a specific reason why we wouldn't allow
<button type="button">to trigger ajax?Comment #63
lauriiiMoving to needs review for #62.
Comment #64
idebr commented#62 Drupal has historically only used input elements, so many components do not support
<button type="button">simply because the markup was not available. There is no technical reason why a<button>should not be able to trigger ajax.Comment #66
lendudeknown random fail, #3099427: [random test failure] FieldLayoutTest::testEntityView()
Comment #67
lauriiiI would prefer allowing
button[type=button]to trigger ajax too since it seems like there isn't any particular reason to not do that.Comment #68
idebr commented#67 Not sure, a button[type="button"] should not trigger a form submit:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button
Comment #70
casey commentedComment #72
ugintl commented#52 did not apply to 8.9. Should I try #70?
Comment #73
neclimdulI don't think 70 would apply to 8.9. I've made a quick convenience patch though for 8.9 even though I don't expect this will be back ported to 8 at this point.
70 failed because it dropped the .theme file so the test failed. Here's basically the same thing but it should pass.
This interdiff is against 70 to show what I fixed but this is the same patch as 52 rerolled onto 9.1.x. There would be no interdiff to 52 because there was just some whitespace conflicts from a es6 transpiler changes and some other patch offset conflicts.
Reroll is not a review, I haven't actually looked at this in a long time just passing through and helping out.
Comment #75
lendudeLets see if this gets it back to green on 9.1.x
Comment #77
idebr commentedThe patch in #75 contains an unrelated file `./core/.phpunit.result.cache`
Comment #78
vsujeetkumar commentedRe-roll patch created for 9.2.x, Also removed unreated file './core/.phpunit.result.cache' from the patch, Please have a look and advise.
Comment #79
idebr commentedcore/modules/views/js/ajax_view.es6.js does not pass eslint validation
Comment #80
vsujeetkumar commentedFixed cs issues.
Comment #82
b_sharpe commentedWorks as intended and has test coverage, lets get this in!
Comment #83
bramdriesen+1 also tested this and it indeed does what it needs to do :)
Comment #84
choudouhu commentedfor version 9.1.9, 1551534-75.patch not working
Comment #85
choudouhu commentedFor version 9.1.9, 1551534-75.patch not working
Comment #86
bramdriesen@choudouhu Use the latest one (#80) instead of a year old patch :-)
Comment #88
effulgentsia commentedAdding issue credits for reviewers and testers, and for @rfbrandsma from #2897276: Allow the attachment of AJAX exposed form behavior to a button of type submit .
Also, reclassifying this as a bug and retitling accordingly.
Also, reuploading #80 to get a new test run on Drupal 9.3, as well as a test-only patch to make sure that it fails as expected without the JS fix.
Comment #89
effulgentsia commentedResponding to reviews that didn't get incorporated into the patch:
@lauriii in #67:
I agree with #68's answer to this that the ajax that we're triggering is effectively a form submit so it should only apply to
type="submit"buttons. Also, this way, we match the behavior that's in Views for Drupal 7 in https://git.drupalcode.org/project/views/-/blob/7.x-3.x/js/ajax_view.js#L90, per the commit that happened in #12. If we discover a need to also trigger this for other types of buttons, we can have a followup issue to add that.@droplet in #33:
If we want to do this, let's do it in a followup. The existing code in HEAD targets
input[type=submit], andbutton[type=submit]has essentially the same semantics, so refactoring fromtag[attr]is out of scope for this issue.Comment #96
effulgentsia commentedCrediting people from another duplicate: #2998908: Views exposed form Ajax selector doesn't work on buttons.
Comment #101
effulgentsia commentedMissed some in #96.
Comment #104
effulgentsia commentedPushed to 9.3.x. Tagging for a release notes mention, and added the release notes snippet to the issue summary.
Thank you to the many people who tested, reviewed, and rerolled this over the years.
Comment #105
effulgentsia commentedComment #106
effulgentsia commentedBy the way, there are several other JS files where
input[type=submit]is in a selector andbutton[type=submit]isn't. And there might also be PHP code that treats them differently too. From #2998908-10: Views exposed form Ajax selector doesn't work on buttons:#1671190: Use <button /> form element type instead of <input type="submit" /> is probably the best place to discuss that for now. We may want to open new child issues of that one to fix specific bugs ahead of actually changing core to use
<button>elements itself.