Skip to content
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

Merged
merged 1 commit into from
Dec 22, 2017
Merged

[Popover] Add action property #9588

merged 1 commit into from
Dec 22, 2017

Conversation

gregnb
Copy link
Contributor

@gregnb gregnb commented Dec 21, 2017

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

@gregnb
Copy link
Contributor Author

gregnb commented Dec 21, 2017

Still need to add the unit tests but wondering if this is agreeable ?

Copy link
Member

@oliviertassinari oliviertassinari left a 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?

@@ -78,14 +78,22 @@ export const styles = {
};

class Popover extends React.Component {
componentDidMount() {
if (this.props.updateReference) {
this.props.updateReference(() => {
Copy link
Member

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?

@oliviertassinari oliviertassinari added the component: Popover The React component. label Dec 21, 2017
@oliviertassinari oliviertassinari changed the title [Popover] create updateReference prop to allow update of style and po… [Popover] Update position manually Dec 21, 2017
@oliviertassinari oliviertassinari added the PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI label Dec 21, 2017
@oliviertassinari
Copy link
Member

Still need to add the unit tests but wondering if this is agreeable?

@gregnb Yes, it's close to being mergable :).

@gregnb
Copy link
Contributor Author

gregnb commented Dec 21, 2017

@oliviertassinari took those suggestions and applied them! They are good ideas

@oliviertassinari oliviertassinari added new feature New feature or request PR: accepted and removed PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI labels Dec 22, 2017
@oliviertassinari oliviertassinari changed the title [Popover] Update position manually [Popover] Add action property Dec 22, 2017
@oliviertassinari oliviertassinari merged commit 70873ce into mui:v1-beta Dec 22, 2017
@oliviertassinari
Copy link
Member

@gregnb Good work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Popover The React component. new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants