brownplt / code.pyret.org

Website for serving Pyret to folks.
Other
24 stars 45 forks source link

Styles disappear due to cross-tab interactions. #345

Closed jswrenn closed 4 years ago

jswrenn commented 4 years ago
  1. In tab A, open https://code.pyret.org/editor
  2. In tab B, open https://code.pyret.org/editor#share=1ygUsAC-SLh6-nc-Hqp0cdLkvJiwxyRuV&v=8973759
  3. Close tab B.
  4. Switch to tab A.

Result: screenshot-code pyret org-2020 09 08-13_44_23

thomascastleman commented 4 years ago

It appears the body's class is getting replaced completely (and therefore dropping the theme class which tells it where to get the colors from).

When I inspect I get <body class="1gx416c1bl2ftv1i9i8z592bi8ruzoo9n6zr0ip"> after the interaction. Do you know where this new class is coming from? If we can get it to just add the class instead of removing the previous that may be all we need to do.

jswrenn commented 4 years ago

It seems to be coming from applyTheme.

If you right click the <body> element in Chrome's Inspector, you can set a js breakpoint on attribute modification.

jpolitz commented 4 years ago

Shouldn't there be a guard on this code to only call f if e.key is equal to the provided key?

https://github.com/brownplt/code.pyret.org/blob/horizon/src/web/js/localSettings.js#L25

jpolitz commented 4 years ago

(@thomascastleman I wouldn't assume that class is supposed to be added to body at all)

jpolitz commented 4 years ago

I think this is fixed/deployed now, could someone else check the repro @jswrenn gives above to confirm?

thomascastleman commented 4 years ago

@jpolitz It appears to work now! Thanks