-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add missing mouseover before click for select and radio elements. #14
base: main
Are you sure you want to change the base?
Conversation
@vever001 thanks for the MR. Any chance you could add test coverage for this? Have a look in \Behat\Mink\Tests\Driver\Custom\LargePageClickTest and the mink driver-test-suite dependency. |
I'm a bit confused... I tried to reproduce with tests initially but couldn't. The test passes if we comment out the JS that adds the attribute. It looks like scrollIntoView block: 'center' fixes it but I'm not sure what is going on exactly... |
@@ -953,7 +953,7 @@ public function mouseOver(string $xpath) | |||
private function scrollElementIntoView(Element $element): void { | |||
$script = <<<JS | |||
var e = arguments[0]; | |||
e.scrollIntoView({ behavior: 'instant', block: 'end', inline: 'nearest' }); | |||
e.scrollIntoView({ behavior: 'instant', block: 'center', inline: 'nearest' }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking about this change. I'm wondering why it is necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the fix from #15 but it didn't solve the issue.
I'll spend some more time shortly to try to understand what's going on but I'm not sure the issue is specific to my project, I think it's an edge case (with size attributes?).
If we revert this line, the test fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We faced similar issue after upgrading Drupal 10.2 to 10.3, where behat/mink-selenium2-driver
got replaced with this library. The tests started to fail and patching the e.scrollIntoView()
block argument to center
fixed the issues of layouts with floating toolbar receiving the press/click events.
I think maybe in this instance this might be very related to #15 - and given the way your project works maybe it is your projects job to do the necessary scrolling. It's really tricky when people overlap elements that are suppose to receive clicks. |
I just hit this on another project. This happens somewhat intermittently for elements where the browser has to scroll down. I think it's either:
|
Following #10 and #13 logic, I noticed radios and select elements also require a scrollIntoView which are currently missing. Without this, we get MoveTargetOutOfBounds exception when attempting to click on select/radios which are out of the viewport.