-
Notifications
You must be signed in to change notification settings - Fork 842
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
[EuiFlyoutResizable] Add optional onResize
callback
#7464
Conversation
// To reduce unnecessary calls, only fire onResize callback: | ||
// 1. After initial mount / on user width change events only | ||
// 2. If not currently mouse dragging |
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.
I can see a need for receiving continuous updates during mouse dragging, and I think we may eventually have to implement it. We usually let users deal with debouncing these calls when necessary, so maybe just do the same thing here and keep it consistent? Alternatively, we could provide a configuration prop like onResizeUpdateFrequency: 'once' | 'always'
but that sounds like a new pattern we'd need to introduce to other places as well.
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.
That's fair, but I think I'd rather wait until it's requested? TBH I kind of felt that the onResizeStart
and onResizeEnd
callbacks/contributions to EuiResizableContainer
were stopgaps for this exact reason - consumers/devs only wanted the final width at the end of resize, not on mouse drag.
a new pattern we'd need to introduce to other places as well
FWIW EuiFlyoutResizable is already different from EuiResizableContainer in this regard, in that its width(s) are not controllable unlike EuiResizableContainer. I don't think it needs to be 1:1 on this, but if we feel differently we can change it - it's a beta component after all
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.
Actually, why don't we double check with the dev who requested this feature! @mykolaharmash - for EuiFlyoutResizable
's new onResize
callback, would you want the updated width during the user drag event (potentially being called many times per second), or would you only want the final width after the user is done dragging?
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.
Hey folks! Sorry for a delayed response. For the usecase I had in mind (just saving the preferred size and restoring it later) having a single callback when the event end is totally fine. The only potential usecase I imagine where I'd need a continuous stream of events is when I'd want to some other layout or element on the page react to the updated flyout size, but it's only hypothetical, I don't have a realy need for this at the moment.
Thank you for implementing this 🙌 🙏
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.
I'm totally fine leaving the current onResize
behavior as is since this is a beta component. LGTM!
This reverts commit cf3d9ac.
Thanks Tomasz! @mykolaharmash, please feel free to drop a comment or open an issue if you need |
Preview staging links for this PR:
|
💚 Build Succeeded
History
|
`v92.1.1`⏩`v92.2.1` --- ## [`v92.2.1`](https://github.com/elastic/eui/releases/v92.2.1) **Bug fixes** - Removed unintentional i18n tokens in prior release that should not have been exported ## [`v92.2.0`](https://github.com/elastic/eui/releases/v92.2.0) - Updated `EuiFlyoutResizable` with new optional `onResize` callback ([#7464](elastic/eui#7464)) **Bug fixes** - Fixed an issue in `EuiResizableContainer` where `onResizeEnd` could become a stale closure when renders occured between resize start and end, resulting in an outdated version of a consumer's `onResizeEnd` callback being called ([#7468](elastic/eui#7468)) - Fixed `EuiTextArea` to correctly fire `onChange` callbacks on clear button click ([#7473](elastic/eui#7473)) - Fixed `EuiContextMenu`'s panel titles & items to not show underlines on hover for non-interactive elements ([#7474](elastic/eui#7474)) **Deprecations** - Remove unused public `EuiHue` and `EuiSaturation` subcomponent exports. Use the parent `EuiColorPicker` component instead ([#7460](elastic/eui#7460)) - Remove unused public `EuiCommentTimeline` subcomponent export. Use the parent `EuiComment` or `EuiCommentList` components instead. ([#7467](elastic/eui#7467))
`v92.1.1`⏩`v92.2.1` --- ## [`v92.2.1`](https://github.com/elastic/eui/releases/v92.2.1) **Bug fixes** - Removed unintentional i18n tokens in prior release that should not have been exported ## [`v92.2.0`](https://github.com/elastic/eui/releases/v92.2.0) - Updated `EuiFlyoutResizable` with new optional `onResize` callback ([elastic#7464](elastic/eui#7464)) **Bug fixes** - Fixed an issue in `EuiResizableContainer` where `onResizeEnd` could become a stale closure when renders occured between resize start and end, resulting in an outdated version of a consumer's `onResizeEnd` callback being called ([elastic#7468](elastic/eui#7468)) - Fixed `EuiTextArea` to correctly fire `onChange` callbacks on clear button click ([elastic#7473](elastic/eui#7473)) - Fixed `EuiContextMenu`'s panel titles & items to not show underlines on hover for non-interactive elements ([elastic#7474](elastic/eui#7474)) **Deprecations** - Remove unused public `EuiHue` and `EuiSaturation` subcomponent exports. Use the parent `EuiColorPicker` component instead ([elastic#7460](elastic/eui#7460)) - Remove unused public `EuiCommentTimeline` subcomponent export. Use the parent `EuiComment` or `EuiCommentList` components instead. ([elastic#7467](elastic/eui#7467))
`v92.1.1`⏩`v92.2.1` --- ## [`v92.2.1`](https://github.com/elastic/eui/releases/v92.2.1) **Bug fixes** - Removed unintentional i18n tokens in prior release that should not have been exported ## [`v92.2.0`](https://github.com/elastic/eui/releases/v92.2.0) - Updated `EuiFlyoutResizable` with new optional `onResize` callback ([elastic#7464](elastic/eui#7464)) **Bug fixes** - Fixed an issue in `EuiResizableContainer` where `onResizeEnd` could become a stale closure when renders occured between resize start and end, resulting in an outdated version of a consumer's `onResizeEnd` callback being called ([elastic#7468](elastic/eui#7468)) - Fixed `EuiTextArea` to correctly fire `onChange` callbacks on clear button click ([elastic#7473](elastic/eui#7473)) - Fixed `EuiContextMenu`'s panel titles & items to not show underlines on hover for non-interactive elements ([elastic#7474](elastic/eui#7474)) **Deprecations** - Remove unused public `EuiHue` and `EuiSaturation` subcomponent exports. Use the parent `EuiColorPicker` component instead ([elastic#7460](elastic/eui#7460)) - Remove unused public `EuiCommentTimeline` subcomponent export. Use the parent `EuiComment` or `EuiCommentList` components instead. ([elastic#7467](elastic/eui#7467))
Summary
Per recent EUI feedback - adds an
onResize
callback where the latest flyout width is passed, which allows consumers to do things like, e.g. save user preference by storing the flyout width inlocalStorage
QA
General checklist
@default
if default values are missing)and playground toggles- [ ] Added documentation- [ ] Checked Code Sandbox works for any docs examplesjest andcypress tests- [ ] If applicable, added the breaking change issue label (and filled out the breaking change checklist)