Skip to content

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.

2 participants