useBreakpointIndex
: attach resize
event listener to window
instead of document
#33902
Conversation
TIL! Thanks for the fix. FWIW I still think this "feature" should be carefully evaluated, whether it's actually a good one to include now or something we can just add in the future. Of course it's usages are already in non-experimental components (like Flex) so it might be too late to do so. |
I agree with you — I'm also not a fan of this pattern where an array of values are applied given a responsive configuration. It just feels a bit of an unnecessary construct around what could be easily implemented via CSS (or a separate utility from each component anyway). It seems that the only components using this pattern are |
04e6ce5
to
5f12042
ciampo commentedAug 5, 2021
Description
Fix a bug in the
useBreakpointIndex
component utility hook, where theresize
event listener was previously attached to thedocument
object.This was resulting in the event listener function never being called, since the
resize
event only gets fired on thewindow
object.The fix is quite simple — change
document
towindow
.How has this been tested?
One way to test this is to check the
Flex
component's Storybook example:row
tocolumn
(and viceversa)Screenshots
Before
flex-breakpoint-before.mp4
After
flex-breakpoint-after.mp4
Types of changes
Bug fix
Checklist:
*.native.js
files for terms that need renaming or removal).