Capybara.disable_animation also disables view transitions#2790
Open
eric-eye wants to merge 1 commit intoteamcapybara:masterfrom
Open
Capybara.disable_animation also disables view transitions#2790eric-eye wants to merge 1 commit intoteamcapybara:masterfrom
eric-eye wants to merge 1 commit intoteamcapybara:masterfrom
Conversation
eric-eye
commented
Dec 22, 2024
|
|
||
| DISABLE_CSS_MARKUP_TEMPLATE = <<~CSS | ||
| %<selector>s, %<selector>s::before, %<selector>s::after { | ||
| %<selector>s, %<selector>s::before, %<selector>s::after, ::view-transition-group(*) { |
Author
There was a problem hiding this comment.
https://developer.mozilla.org/en-US/docs/Web/CSS/::view-transition-group
My intention is that this would cover the root animation and any named animations.
eric-eye
commented
Dec 22, 2024
|
|
||
| input.click(function(event){ | ||
| message.show(); | ||
| }); |
Author
There was a problem hiding this comment.
The sequence of events:
- User clicks link
- Button slowly fades into view
- Clicking button reveals a message
I chose this flow because even with animations, the browser is still rendering the content immediately and can be "seen" by Capybara. Issuing a click, however, will not be possible for elements which are animating.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Animations provided by the View Transition API are not disabled when
Capybara.disable_animationsis set. This can lead to Capybara not being able to interact with certain elements before a view transition has completed.For a personal project, this manifested as an
inputwhich could not be clicked until the transition completed, even though the page content could be ready.Potential Solution
I wanted to see what it would look like to do the simplest thing possible with
Capybara::Server::AnimationDisablerto cover view transitions. While this works, it does betray the "selector" feature ofdisable_animations, as this behaves the same way even if a selector is supplied as if it were set totrue.As I understand it, the View Transition API's CSS pseudo-selectors do not allow animation characteristics (such as
animation-duration) to be changed for individual elements in the normal DOM tree. Instead, they are controlled via named view transitions and pseudo-selectors that exist in their own tree. Transition names also cannot be applied to more than one element, so using a broad selector to assign dummy transition names would likely cause bugs.I'm curious what others think about this. I didn't want to add a lot of complexity to this API without getting some early feedback. But a couple of possibilities I'd considered:
AnimationDisablermiddleware to support itAnimationDisablerI may also be mistaken about not being able to use existing selector-driven approach. If this could be made to work, then that would simplify this problem quite a bit.