Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
It turns out that this is not a duplicate. What's actually happening is that parts of the form (including the flags) get regenerated by a function that's called on the JS page. The Flag module sets the flag's "destination" attribute to the URL of the current page--that is, the page on which the flag is generated--and this becomes the JS page after the form has been submitted once via JS.
However, this isn't actually a problem with the like/unlike flag, because the destination attribute never gets called. It is a problem with the Delete flag, because that flag sends you to a confirmation form which redirects to the destination parameter on submission.
Experimenting with this has revealed another problem, however: it seems that clicking the flags can make the JavaScript that handles toggling the form be added multiple times to the page. This causes the form to toggle several times when it is clicked, if form toggling is enabled. I'm not sure when or how this happens, but it needs to be addressed.
Fixed in dev. I removed the flags from the form because there isn't a clean way to avoid this behavior. The more typical use should be within Views anyway.
Comments
Comment #1
icecreamyou commentedOKAY
This isn't technically a duplicate of #437522 but the source of the problem is the same, and fixing that issue will fix this one as well.
Comment #2
icecreamyou commentedIt turns out that this is not a duplicate. What's actually happening is that parts of the form (including the flags) get regenerated by a function that's called on the JS page. The Flag module sets the flag's "destination" attribute to the URL of the current page--that is, the page on which the flag is generated--and this becomes the JS page after the form has been submitted once via JS.
However, this isn't actually a problem with the like/unlike flag, because the destination attribute never gets called. It is a problem with the Delete flag, because that flag sends you to a confirmation form which redirects to the destination parameter on submission.
Experimenting with this has revealed another problem, however: it seems that clicking the flags can make the JavaScript that handles toggling the form be added multiple times to the page. This causes the form to toggle several times when it is clicked, if form toggling is enabled. I'm not sure when or how this happens, but it needs to be addressed.
Comment #3
icecreamyou commentedFixed in dev. I removed the flags from the form because there isn't a clean way to avoid this behavior. The more typical use should be within Views anyway.