Skip to content
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

Added Capybara.disable_animation_extra_css option to insert extra CSS in Capybara::Server::AnimationDisabler::DISABLE_MARKUP_TEMPLATE #2418

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ndbroadbent
Copy link
Contributor

@ndbroadbent ndbroadbent commented Oct 30, 2020

This is a follow-up for my previous PR: #2399

I've added a new Capybara.disable_animation_extra_css option that can be used to add additional CSS rules to the AnimationDisabler middleware, in case there are any custom ways that people need to disable animation.

I personally need to use caret-color: transparent; to hide any cursors in inputs. I have some screenshot tests that ensure that some inputs are visually correct on the page, so these would sporadically fail if the cursor appeared in the reference screenshot, and then disappeared in the test screenshot.

I'm currently doing this:

  Capybara::Server::AnimationDisabler.class_eval do
    # rubocop:disable Lint/ConstantDefinitionInBlock
    DISABLE_MARKUP_TEMPLATE_CARET_TRANSPARENT = <<~HTML
      <script defer>(typeof jQuery !== 'undefined') && (jQuery.fx.off = true);</script>
      <style>
        %<selector>s, %<selector>s::before, %<selector>s::after {
          transition: none !important;
          animation-duration: 0s !important;
          animation-delay: 0s !important;
          scroll-behavior: auto !important;
          caret-color: transparent;
        }
      </style>
    HTML
    # rubocop:enable Lint/ConstantDefinitionInBlock

    def initialize(app)
      @app = app
      @disable_markup = format(
        DISABLE_MARKUP_TEMPLATE_CARET_TRANSPARENT,
        selector: self.class.selector_for(Capybara.disable_animation)
      )
    end
  end

I'd like to get rid of the class_eval and replace it with this line: Capybara.disable_animation_extra_css = 'caret-color: transparent;'

@twalpole
Copy link
Member

I don't want to add another setting for this. If you implement it so Capybara.disable_animation optionally accepts multiple arguments I'd accept it

Capybara.disable_animation = true, 'caret-color: transparent;'

for instance

@ghost
Copy link

ghost commented Dec 29, 2023

I would love to have the feature @twalpole mentioned. Did this ever get implemented? The default disable_animations doesn't work for Bootstrap 4.6 modal fades.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants