Rails dark mode flickering

Viewed 19

I implemented dark mode for my Rails application but after I enable it, when I want to change the page using link_to my background is flickering. This happens twice.

This is my body, adding the class depending on the theme user choose.

  %body.pb-md-0.pb-3{class: cookies[:theme]}

And this is the way I change the theme

          =link_to theme_path(theme: :dark) do
             ....image here

this is the theme_path

  def display
      cookies[:theme] = {
          value: params[:theme].to_sym
      }
    redirect_to language_and_theme_path
  end

The only thing that works is refreshing the page, but I don't really want to refresh the page after every theme change.

0 Answers
Related