You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is due to #2531, which updated Responsive to use document.documentElement.clientWidth, instead of window.innerWidth. They are very technically different measurements, and the change has introduced the unexpected result I showed above. This is because clientWidth does not include the width of the scrollbar in the measurement, so it appears the width is 768px - 17px. Also, I have many tests that rely on stubbing window.innerWidth, and 0.78.3 has broken them all.
My proposal to fix the issue and more
Revert fix(Responsive): use root element client width #2531 and use window.innerWidth as the default way of measuring width for the Responsive component. Semantic UI's responsive breakpoints should take into account the scrollbar, which document.documentElement.clientWidth does not. Without reverting back, the use of <Responsive {...Responsive.mobileOnly} />, etc. will not work as expected.
Add a new property to Responsive that allows developers to use a custom measurement for the width: <Responsive getWidth={() => document.documentElement.clientWidth} />. This would allow @autarc measure what he wants without introducing the backwards incompatible change.
Fix the false-positive tests in Responsive-test.js. I have noticed some of the Responsive tests aren't testing the right thing, and they are passing when they should not. I'll fix this and explain what was wrong.
Only set state when width actually changes. Right now, every window.resize event causes Responsive to set the width, causing unneeded renders. This is mostly notable on mobile devices which hide and show the URL bar at the top on vertical scrolling. Scrolling on mobile devices that cause the URL bar to show/hide, triggers a window.resize event and Responsive renders, when not needed.
The text was updated successfully, but these errors were encountered:
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you've completed all the fields in the issue template so we can best help.
We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
andrewferk
changed the title
Recent backwards incompatible change to Responsive component using document.documentElement.clientWidth
Recent backwards incompatible change to Responsive component using document.documentElement.clientWidth
Mar 7, 2018
layershifter
changed the title
Recent backwards incompatible change to Responsive component using document.documentElement.clientWidth
Responsive: incompatible change using document.documentElement.clientWidth
Mar 11, 2018
Steps
<Responsive maxWidth={767}>Only mobile</Responsive>
Expected Result
The "Only mobile" text does not render/display.
Actual Result
The "Only mobile" text does render/display.
Version
0.78.3
My analysis for the issue
This is due to #2531, which updated
Responsive
to usedocument.documentElement.clientWidth
, instead ofwindow.innerWidth
. They are very technically different measurements, and the change has introduced the unexpected result I showed above. This is becauseclientWidth
does not include the width of the scrollbar in the measurement, so it appears the width is768px - 17px
. Also, I have many tests that rely on stubbingwindow.innerWidth
, and 0.78.3 has broken them all.My proposal to fix the issue and more
window.innerWidth
as the default way of measuring width for theResponsive
component. Semantic UI's responsive breakpoints should take into account the scrollbar, whichdocument.documentElement.clientWidth
does not. Without reverting back, the use of<Responsive {...Responsive.mobileOnly} />
, etc. will not work as expected.Responsive
that allows developers to use a custom measurement for the width:<Responsive getWidth={() => document.documentElement.clientWidth} />
. This would allow @autarc measure what he wants without introducing the backwards incompatible change.Responsive-test.js
. I have noticed some of theResponsive
tests aren't testing the right thing, and they are passing when they should not. I'll fix this and explain what was wrong.window.resize
event causesResponsive
to set the width, causing unneeded renders. This is mostly notable on mobile devices which hide and show the URL bar at the top on vertical scrolling. Scrolling on mobile devices that cause the URL bar to show/hide, triggers awindow.resize
event andResponsive
renders, when not needed.The text was updated successfully, but these errors were encountered: