-
Notifications
You must be signed in to change notification settings - Fork 844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed issue with EuiResizeObserver
fallback
#3088
Fixed issue with EuiResizeObserver
fallback
#3088
Conversation
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? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
ResizeObserver
so that they won't catch the window resizing events properly.The fix is to add resize event listener to them.
Before:
After:
Checklist