-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Popover] Add action property #9588
[Popover] Add action property #9588
Conversation
Still need to add the unit tests but wondering if this is agreeable ? |
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.
The callback property sounds like the way to go. It's the same pattern than with refs.
I have been doing something similar on react-swipeable-views to solve the same use case. The only difference is that we use a generic name: action
Name | Type | Default | Platform | Description |
---|---|---|---|---|
action | function(hooks) | browser | This is callback property. It's called by the component on mount. This is useful when you want to trigger an action programmatically. It currently only supports updateHeight() action. |
It's also something that we might need to solve Tabs ink repositioning issue. What about using the same property name and nesting the hooks into an object?
src/Popover/Popover.js
Outdated
@@ -78,14 +78,22 @@ export const styles = { | |||
}; | |||
|
|||
class Popover extends React.Component { | |||
componentDidMount() { | |||
if (this.props.updateReference) { | |||
this.props.updateReference(() => { |
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.
This block looks exactly like the one we have to handle the resize event.
Can we factorize the code?
@gregnb Yes, it's close to being mergable :). |
@oliviertassinari took those suggestions and applied them! They are good ideas |
@gregnb Good work 👍 |
Here's an implementation of how I could see access to the getPositioningStyle method. It's simply a reference callback which will allow access to outside components to trigger updates. It is useful for content that could come in delayed and you need to reposition the Popover manually
Closes #9584