[Bug]: dropdown is scrolled into view even though it's already fully visible
🚀 Feature Request
As documented in here:
https://playwright.dev/docs/actionability#stable
it would be beneficial to expose 'stable' state as additional option in Locator.waitFor.
At the moment the only way to make sure element is not animating is implicit actionability check execution as part of actions involving clicking/tapping. Implicit actionability checks includes scrolling element into view.
Example
waitFor(options?: {
// ...
state?: "attached"|"detached"|"visible"|"hidden"|"stable";
// ...
}): Promise<void>;
Motivation
In very specific cases scrolling an element which is still animating closes it (some custom dropdowns might be implement like that). Therefore having a way to have this check performed alone would save headaches and custom stability checks implementation.
Hi, thanks for opening the feature request. Could you elaborate on your usecase where you care about animations being done, but are not clicking / tapping afterwards? Is it related to screenshotting the element?
@Skn0tt It is about custom dropdowns which animate during opening. I would like to be able to:
- check if the opened dropdown options are visible, enabled, stable etc.
- I do NOT want it to scroll it into view - for some reason playwright sometimes changes viewport position/scrolls element into view even if the element is already fully visible (maybe this is a separate issue)
- I do want to click the element
The implementation used in the application in my case makes dropdown disappear after scrolling - so either I need a way to selectively disable scrolling element into view as part of native click option OR I would like to explicitely call for stability check and then call dispatchEvent('click'). Both are not possible at the moment and I cannot see any other workaround for it without additional custom implementation
Maybe trial could help you? https://playwright.dev/docs/api/class-locator#locator-click-option-trial
Maybe
trialcould help you? https://playwright.dev/docs/api/class-locator#locator-click-option-trial
It does not - I already tried it. Setting trial: true performs scrolling into view as well unfortunately
We discussed this with the team on the meeting. trial: true scrolls into view because we need that for our actionability checks. It's weird that we're scrolling even though the element is already fully visible, though, that sounds like a bug - could you provide us with a reproduction case for it?
We need a minimal reproduction that we could run locally to make this report actionable. Please file a new one and link to this issue when you get back to it!