Problem/Motivation
When adding a link to a webform dialog the dialog modal is not working on a touch device. Instead of opening the modal, it follows the link.
Steps to reproduce
Create a link like the following:
<a href="/en/form/testform?source_entity_type=ENTITY_TYPE&source_entity_id=ENTITY_ID" class="webform-dialog" data-dialog-options="{"width":800}">Open Webform Dialog</a>
and click on it - it should open a dialog like on desktop-devices, but it follows the link on touch-devices. This is also happening in the inspector with touch-simulation enabled.
Proposed resolution
Add touchstart event in webform.dialog.js @ line 83. Change from click to touchstart click
| Comment | File | Size | Author |
|---|---|---|---|
| #18 | 3427966-revert-mr433-use-click-to-open-modal.patch | 632 bytes | anruether |
Issue fork webform-3427966
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
roromedia commentedComment #3
roromedia commentedComment #4
roromedia commentedComment #6
jrockowitz commentedComment #8
jrockowitz commentedComment #10
jrockowitz commentedComment #12
anybodySorry, but I have to disagree this was a good idea. Touch events are special, yes, but at least it should at least have been
touchendinstead oftouchstart.Using
touchendensures the event fires when the user lifts their finger, reducing accidental triggers.Still, I think it should not be needed at all in modern browsers, according to this answer: https://stackoverflow.com/a/11398089/10031165
Should we reopen this or create a follow-up?
Which browser and device did you use @roromedia?
Comment #13
thomas.frobieterMaybe @roromedia could provide the affected browser? If I remind corretly, this where a Safari bug, not sure if click is still problematic in iOS Safari.
Comment #14
roromedia commentedThe bug occurred on iOS (when tested I used the latest stable version and versions below as well) iPads with Safari as standard browser.
Comment #15
thomas.frobieterThanks @roromedia.
So I changed the task title accordingly.
Just came across this problematic behaviour again on Android. Extremely annoying when simple scrolling triggers the webform dialog.
We should try if a simple cursor: pointer; solves the problem with the click event on Safari, see:
https://stackoverflow.com/questions/24077725/mobile-safari-sometimes-doe...
EDIT: Or use the new 'pointerup' event instead.
Comment #16
thomas.frobieterI've tested with 'pointerup' instead 'click touchstart' and it seems to work well on all devices and browsers.
But someone should try this on a real Iphone, I only have the simulator.
So should we re-open this issue or create a new one?
Comment #17
anybody@jrockowitz could you reopen this one to fix it? Or would you prefer a follow-up?
Comment #18
anruether@thomas.frobieter On an Iphone SE2 18.3.2, Safari:
I'll attach a patch that reverts this issues patch, because we rather use a link for some safari users, instead of interfering with everybody's scrolling.
edit: @roromedia So your issue is only with ipads? Because I can't reproduce it on my iphone. It would be good then to get more info on how widespread the faulty behavior is, so we don't repair something for a few, but introduce regressions for a lot.
Comment #19
thomas.frobieterThat's strange. Safari 13.1/13.2 should support pointerup. I think we should debug this, as the pointer event sounds like the cleanest solution to me.
Here is a Pen to test the events: https://codepen.io/thomas-frobieter/pen/qEdNoEr
I can confirm that the link opens after the pointerup event is fired. For reasons, preventDefault() is not working. I will do further research on this.
EDIT: Okay, when using 'pointerup' you also need to register 'click' and add preventDefault() for both.
Comment #20
thomas.frobieterCan someone with an Apple touch device please test the 'pointerup click' button? => https://codepen.io/thomas-frobieter/full/qEdNoEr
I have tried on the iOS Simulator and it seems to work well.
If the real device test also works well, I will create a follow up issue.
Comment #21
liam morlandThis has caused #3506020: When scrolling, the modal window opens automatically. Please review the fix in that issue.
Comment #22
anybody@liam morland: There's nothing to review yet. We should either fix both issues over at #3506020: When scrolling, the modal window opens automatically or here. They are very closely related, nearly the same and surely have the same fix. As this one is closed, maybe better move over?
So ==> Further work here: https://www.drupal.org/project/webform/issues/3506020 <==
Comment #23
liam morlandYes, please work in the other issue. There isn't a patch, but there is a prose description of the change in comment 4.