Skip to content

Conversation

@thompsongl
Copy link
Contributor

@thompsongl thompsongl commented Feb 13, 2019

Summary

  • Adds EuiResizeObserver component as an optimized path toward more efficient component resize eventing.
    • Extends new EuiObserver component that handles ref and lifecycle management required by both EuiResizeObserver and EuiMutationObserver.
    • Falls back to MutationObserver in browsers that don't (yet) support the ResizeObserver API. Only Chrome and Opera currently have support.
  • Resolves [EuiContextMenu] Custom panel content sometimes cut off #1553 by composing EuiResizeObserver in EuiContextMenuPanel
    • EuiContextMenuPanel has existing updateHeight logic, but only accounted for parent state changes. Internal content changes now register height adjustments.
    • Simplifies lifecycle logic by relying more on DOM events

Checklist

  • This was checked in mobile
  • This was checked in IE11

- [ ] This was checked in dark mode

  • Any props added have proper autodocs
  • Documentation examples were added
  • A changelog entry exists and is marked appropriately
  • This was checked for breaking changes and labeled appropriately
  • Jest tests were updated or added to match the most common scenarios

- [ ] This was checked against keyboard-only and screenreader scenarios
- [ ] This required updates to Framer X components

@chandlerprall
Copy link
Contributor

I feel EuiResizeObserver should always return an object with width and height, instead of the observed event entry. As EuiObserver has the childNode ref member, the resize observer could childNode.getBoundingClientRect() and return the element dimensions. Thoughts?

@thompsongl
Copy link
Contributor Author

This is a good idea. I was weighing options for the return value and initially settled on a "give them everything" approach. After adding the docs, though, it felt odd with the MutationObserver fallback.
Standard return object will address this, I think.

@thompsongl
Copy link
Contributor Author

@chandlerprall updated the response object to be {height, width}

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; tested resize observer docs locally in all Chrome, FF, Safari, Edge, & IE11.

@thompsongl thompsongl merged commit 895a07c into elastic:master Feb 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants