Fixed issue with EuiResizeObserver fallback#3088
Fixed issue with EuiResizeObserver fallback#3088thompsongl merged 7 commits intoelastic:masterfrom PeterSenpai:peter/fix_resizing_issue
EuiResizeObserver fallback#3088Conversation
|
Since this is a community submitted pull request, a Jenkins build has not been kicked off automatically. Can an Elastic organization member please verify the contents of this patch and then kick off a build manually? |
thompsongl
left a comment
There was a problem hiding this comment.
Thanks, @PeterSenpai
This does address 1 of 2 points made in the issue. The second point ("confirm that a newly computed size is, in fact, different from the previously known one") is just as important as the resize listener, and we will want to accomplish it as part of this fix.
Also, as this is a bugfix, you'll need to add a changelog entry (see: https://github.com/elastic/eui/blob/master/CONTRIBUTING.md#documentation)
Thank you @thompsongl for the feedback! const _currentDimensions = useRef(size);
const setSize = useCallback(dimensions => {
if (
_currentDimensions.current.width !== dimensions.width ||
_currentDimensions.current.height !== dimensions.height
) {
_currentDimensions.current = dimensions;
_setSize(dimensions);
}
}, []);I might misundsertand the 2nd point and can totally be wrong. |
|
jenkins test this
You are correct! 😅 This is looking good. |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3088/ |
|
jenkins test this |
EuiResizeObserver fallback
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3088/ |
thompsongl
left a comment
There was a problem hiding this comment.
Upon further investigation, the code in src/components/observer/resize_observer.tsx line 77 does not apply to the standard EuiResizeObserver method, only the useResizeObserver hook.
So, we still need to account for cases where the callback is not the result of an actual resize event.
Thanks! I will take a look. |
|
Hi, @thompsongl. I added the logic that would check if the size is actually changed. There might be a cleaner way to do it if the function Also when I did filter out the non-resize events, the Please give me feedback on my approach and what needs to be changed. |
|
jenkins test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_3088/ |
thompsongl
left a comment
There was a problem hiding this comment.
There might be a cleaner way to do it if the function makeResizeObserver(line 69) doesn't have to return a MutationObserver.
Yeah, but we do need to support the MutationObserver fallback method. Your current code looks good 👍
Testing updates look good, also
Summary
Fixes #3044
The cause was mentioned in the issue.
Basically, Safari and IE11 do not support
ResizeObserverso that they won't catch the window resizing events properly.The fix is to add resize event listener to them.
Before:

After:
Checklist