Giter VIP home page Giter VIP logo

Comments (12)

dbernheisel avatar dbernheisel commented on July 18, 2024 14

For those finding this and use Tailwind, this fixed it for me:

# config/dev.exs
config :my_app, MyAppWeb.Endpoint,
  live_reload: [
    iframe_attrs: [style: "display: none"],   # <-- add this
    patterns: [...]
  ]

-- EDIT, adjusted to use style attribute instead of Tailwind class to avoid needing to configure PurgeCSS

from phoenix_live_reload.

josevalim avatar josevalim commented on July 18, 2024 9

v1.3.1 is out!

from phoenix_live_reload.

josevalim avatar josevalim commented on July 18, 2024 2

If you want to actually customize it to something else, style makes it impossible, which is why we removed it.

from phoenix_live_reload.

josevalim avatar josevalim commented on July 18, 2024 1

If your css classes are overriding it, then the best is to use CSS to override it again. The issue with using style is that it doesn’t work with CSP, so it is bound to have pitfalls there too. In any case, I learned about hidden’s fragility, so this is good to know. Thank you!

from phoenix_live_reload.

torepettersen avatar torepettersen commented on July 18, 2024 1

Is there any drawback of using both style="display: none" and hidden as default?

from phoenix_live_reload.

nickjj avatar nickjj commented on July 18, 2024

For Tailwind, if you're using the new JIT compiler the above solution posted by @dbernheisel no longer works out of the box.

You also need to add the config file paths to PurgeCSS, such as:

  purge: [
    '/app/assets/**/*.js',
    '/app/config/**/*.exs',
    '/app/lib/hello_web/**/*.eex',
    '/app/lib/hello_web/**/*.leex'
  ]

from phoenix_live_reload.

josevalim avatar josevalim commented on July 18, 2024

Good point. Or alternatively define a rule directly in your css and don't depend on Tailwind for this particular case!

from phoenix_live_reload.

nickjj avatar nickjj commented on July 18, 2024

It looks like another alternative solution is to put width="0" height="0" on the iframe itself. Any chance of this getting re-opened and evaluated as a fix because then it requires no app level custom CSS in every project to workaround this issue.

I've tested it on Windows Chrome, FireFox and Edge and it works.

The idea was taken from the Elixir Forums here: https://elixirforum.com/t/does-anyone-know-why-phoenixs-live-reload-hidden-iframe-is-set-to-be-visible-in-the-dom-by-default/38900/6

from phoenix_live_reload.

josevalim avatar josevalim commented on July 18, 2024

@nickjj can you please send a PR? It would be very welcome!

from phoenix_live_reload.

josevalim avatar josevalim commented on July 18, 2024

Actually, I will go ahead and do it and ship a new release right now, since I have some before bed time. :)

from phoenix_live_reload.

nickjj avatar nickjj commented on July 18, 2024

Are you sure? I'm ok with opening the PR. This isn't a life or death request haha.

The only concern is I haven't tested this on macOS, Safari or other devices (lack of devices).

from phoenix_live_reload.

axelson avatar axelson commented on July 18, 2024

For future reference here is the commit: 13938e9

from phoenix_live_reload.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.