Media query selectors not being applied correctly to element after window size change
Reported by
m...@dthought.net,
Oct 23 2017
|
||||||||
Issue descriptionUserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36 Example URL: https://beta.seeklearning.com.au/ Steps to reproduce the problem: The fastest way to reproduce this is: 1. Open the inspector, with the breakpoint navigator shown 2. Click on a small breakpoint 3. Click on a large breakpoint May need to repeat 2-3 a few times, but eventually it will render incorrectly. Inspecting the element shows that a media query that is not valid for the current screen size is being applied. What is the expected behavior? The correct CSS styling is applied to the element What went wrong? An incorrect breakpoint e.g. (max: 480px) is applied to the element (at e.g. a width of 768px) See video for recording of this behaviour. Does it occur on multiple sites: No Is it a problem with a plugin? No Did this work before? N/A Does this work in other browsers? Yes Chrome version: 62.0.3202.62 Channel: beta OS Version: OS X 10.12.6 Flash Version: We're using React, and there is some JS code that also changes the render across breakpoints. I can't prove this easily, but I suspect either: * Maybe a race condition in the code to evaluate JS/CSS? * Pure conjecture, but perhaps React is taking the element reference, detaching it from the DOM (but keeping it in memory), the breakpoint changes, React notices it needs to re-render it from back to the DOM, however because perhaps it wasn't "attached when the change occurred",styling applied is not updated when it's reinserted, instead keeping the "stale" CSS styles. I'm not sure if that's what it's going to be, but that's why I recorded some video to show it occurring. I've tried to replicate this in both Firefox and Safari, but neither exhibit this behaviour. Note that it only falsely renders for one "resize" event - as soon as you resize again or update the layout in any way, it "corrects" itself. So if you were dragging, and thus triggering resizing multiple times, you may not easily notice this bug.
,
Oct 24 2017
,
Oct 24 2017
I’d note that this is able to reproduce even when the dev tools are closed; its a bit tricky but possible if you resize close to a breakpoint. I believe this may be a bug in Chrome’s layout engine somewhere, not dev tool specific :)
,
Oct 25 2017
Moving to Layout per #c3.
,
Oct 30 2017
Could you please explain what the problem appears to be, it was not clear from either your description or the video. Also, by breakpoint do you mean a media query?
,
Oct 30 2017
,
Oct 31 2017
We've mitigated this issue on the example site by removing media queries, so the example site will no longer show the problem. However, in reference to #c5, I'm happy to try and clarify. The video should show the issue clearly, hopefully some further explanation is helpful. This issue seems important if indeed it's a bug in Chrome's layout calculations. Originally, I noticed that when swapping across two breakpoints (doesn't matter where, just that the breakpoint was crossed, i.e. a media query change occurred), incorrect styles were being matched to an element. In the video you'll see that I started with the "large" size (correct), went to "small" (correct), "large" (correct), "small" (correct), then "large" again - incorrect! But as I had to swap a few times, not 100% reproduceable (but highly so - maybe every third or fourth time it would mess up) If you observe in the video, the input field layout is wrong compared to how it started. Why? Using the inspector, and the parts I point out, Chrome has matched and applied a `(max-width: 480px)` media query to an element, but the document width is 768px wide - this should not have happened. I had the inspector open to show that it was applying the incorrect media query to the element. However, it would occur if I had the inspector closed and instead resized the browser window close to the 480px media query breakpoint. The site is using React, so as noted in my suspicions in the original post, I wonder if maybe something in the unmounting / remounting of elements is happening out of sequence with the calculation of which media queries to apply? Does that help explain the issue? If I can, I'll try and see if I can make a reproducible case outside of the site I'm working on, but it could be a tricky one to pinpoint just what combination of things has caused this.
,
Oct 31 2017
Thank you for providing more feedback. Adding requester "eae@chromium.org" to the cc list and removing "Needs-Feedback" label. For more details visit https://www.chromium.org/issue-tracking/autotriage - Your friendly Sheriffbot
,
Oct 31 2017
Thanks for the clarification. That makes sense. Media queries are handled by the style team I believe, over to them for further triage.
,
Oct 31 2017
Thanks for the report. It's good that you've fixed your site, but unfortunately that leaves us without a repro case. It would be great if we could get a reproducible case for this one.
,
Feb 1 2018
Closing due to inactivity and inability to reproduce. |
||||||||
►
Sign in to add a comment |
||||||||
Comment 1 by manoranj...@chromium.org
, Oct 24 2017