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

[Core] Remove click-awayable mixin #3360

Merged
merged 1 commit into from
Feb 19, 2016

Conversation

newoga
Copy link
Contributor

@newoga newoga commented Feb 17, 2016

Related to #2437

Let me know if we should deprecate instead of remove.

Done:

  • Removed from Snackbar
  • Removed from Menu
  • Removed from TableBody
  • Remove mixins/click-awayable.js and references in index.js

Outstanding:

  • Fix validation error when rendering <noscript/> in <tbody/>

@oliviertassinari
Copy link
Member

I like this solution 👍. I can't see better way to do it.

  • I have founds only one repository that implement a clickaway feature: https://github.com/javierbyte/react-clickaway. They are using our mixin 😁.
  • Regarding the manuallyBindClickAway, that's only used by the Snackbar. We can implement the logic inside the component or use.
  • I'm wondering why RenderToLayer use the touchstart and the click events for the click away.

@newoga
Copy link
Contributor Author

newoga commented Feb 17, 2016

I like this solution 👍. I can't see better way to do it.

Sounds good, I'll continue to pursue this.

Regarding the manuallyBindClickAway, that's only used by the Snackbar. We can implement the logic inside the component or use.

What do you think is the best way to do this? Add a delay prop and let the ClickAwayListener manage the timeout? Or do we need to find a more sophisticated way to let parent component managing binding.

I'm wondering why RenderToLayer use the touchstart and the click events for the click away.

I wondered the same thing. My initial reaction was that RenderToLayer was reimplementing clickaway functionality without the mixin. Any other thoughts?

@oliviertassinari
Copy link
Member

What do you think is the best way to do this?

I think that it's simpler to put the logic inside the Snackbar, I don't think that adding a delay property will be enough.

Indeed, RenderToLayer is reimplementing the clickAway logic. But this component isn't following the classical React lifecycle. I don't think that we can do anything other than using the right event name.

@newoga
Copy link
Contributor Author

newoga commented Feb 18, 2016

  • Implemented ClickAwayListener for TableBody and Snackbar

@@ -0,0 +1,48 @@
/*eslint-disable */
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still need to remove this...

Copy link
Member

Choose a reason for hiding this comment

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

I guess we need to add the PropTypes

@newoga
Copy link
Contributor Author

newoga commented Feb 18, 2016

@oliviertassinari @alitaheri This is almost done. The only way I can currently think of fixing the tbody issue is to not use react-event-listener and just manually bind the events in ClickAwayListener, that way nothing is rendered in the DOM.

The other approach is if react-event-listener just rendered it's children the same way ClickAwayListener does, or if there was a way for it to attach it self at the end of body, that might fix it.

@newoga
Copy link
Contributor Author

newoga commented Feb 18, 2016

@oliviertassinari

Indeed, RenderToLayer is reimplementing the clickAway logic. But this component isn't following the classical React lifecycle. I don't think that we can do anything other than using the right event name.

I think the mouseUp and touchend events used in the mixin seem more appropriate than the click and touchstart events used in RenderToLayer. Do you agree? Should we switch them in this PR?

@oliviertassinari
Copy link
Member

@newoga I was thinking the same. Until I realized that http://jedwatson.github.io/react-select/ is using mousedown and touchstart.
I agree with them. For instance, have a look at the native <select /> behavior.

@alitaheri
Copy link
Member

@newoga

manually bind the events in ClickAwayListener

I think this is indeed better 👍

/>
);

return React.createElement(type, other, listener, children);
Copy link
Member

Choose a reason for hiding this comment

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

What about rendering the children before the listener?

@oliviertassinari
Copy link
Member

@newoga That looks good so far. We are close to merging this 👍.

@oliviertassinari oliviertassinari added PR: needs revision The pull request can't be merged. More details is available on the code review or fails in the CI and removed PR: Needs Review labels Feb 18, 2016
@newoga
Copy link
Contributor Author

newoga commented Feb 18, 2016

Sounds good, I'm going to take another stab at this tonight and hopefully we'll be able to finish it. After this, there is only one component that is using the style-resizable mixin we'll need to take care of. 😄

@rob0rt rob0rt mentioned this pull request Feb 18, 2016
7 tasks
@newoga newoga force-pushed the remove-click-awayable branch 2 times, most recently from 538da4c to 9811cda Compare February 19, 2016 08:15
@newoga
Copy link
Contributor Author

newoga commented Feb 19, 2016

@alitaheri @oliviertassinari Can you look at this revised implementation? I couldn't see a way around the <tbody /> so I implemented the event handlers manually. I tested this across all the components that were using the mixin and it looks like it's working well.

Thanks!

@newoga newoga changed the title [WIP] [Core] Remove click-awayable mixin [Core] Remove click-awayable mixin Feb 19, 2016
@newoga newoga added PR: Needs Review 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 Feb 19, 2016
...other,
} = this.props;

return React.createElement(type, other, children);
Copy link
Member

Choose a reason for hiding this comment

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

How about rendering children directly? const el = ReactDOM.findDOMNode(this); would work anyway. This component no longer needs to render anything extra, it will be like a wrapper that finds it's first node and attached the click away to it. I think it's best to remove type:

return children;

And then render any dom element that we wish to attach it to as the child?

This is not tested, I don't know if it will work or not. just thinking out load 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Mm, that might work (not before though when we were using the react-event-listener). Though we'd have to go through each of the components to add the appropriate type as a child of the ClickAwayListener.

Copy link
Member

Choose a reason for hiding this comment

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

If don't have the time I can take it from here. I have a lot of time today 😁 😎

I think it's time you take some rest anyway O.o You've done great 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One sec, I'm trying it now. If it needs more fixes after feel free to pursue! Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

Sure, Thanks a lot 👍 I'll take it from where ever you leave off 😄

@newoga
Copy link
Contributor Author

newoga commented Feb 19, 2016

@alitaheri Returning this.props.children works (after fixing the components to have the root dom node as a child rather than inline). I also tried to make the timer code snackbar clearer. Feel free take it from here if you want any more changes and you and @oliviertassinari can get this merged. Okay 😴 time.

Thanks @alitaheri! 😁

@alitaheri
Copy link
Member

Well I didn't expect you do it all O.O Thank yo so much @newoga This is beautiful 😍 The implementation is awesome 👍

All green here 👍 😄

@oliviertassinari Feel free to merge if all's good.

oliviertassinari added a commit that referenced this pull request Feb 19, 2016
[Core] Remove click-awayable mixin
@oliviertassinari oliviertassinari merged commit 6878200 into mui:master Feb 19, 2016
@oliviertassinari
Copy link
Member

@newoga Really nice work 👍.

newoga added a commit to newoga/material-ui that referenced this pull request Apr 12, 2016
This fixes a regression that was introduced in mui#3360. The previous `click-awayable` mixin listened on `mouseup` and `touchend` events and the new `ClickAwayListener` was implemented to use `mousedown` and `touchstart` events. This commit changes the events to mimick the behavior from the original mixin.

Resolves mui#3818
aahan96 pushed a commit to aahan96/material-ui that referenced this pull request Apr 19, 2016
This fixes a regression that was introduced in mui#3360. The previous `click-awayable` mixin listened on `mouseup` and `touchend` events and the new `ClickAwayListener` was implemented to use `mousedown` and `touchstart` events. This commit changes the events to mimick the behavior from the original mixin.

Resolves mui#3818
und3fined pushed a commit to und3fined/material-ui that referenced this pull request Apr 20, 2016
This fixes a regression that was introduced in mui#3360. The previous `click-awayable` mixin listened on `mouseup` and `touchend` events and the new `ClickAwayListener` was implemented to use `mousedown` and `touchstart` events. This commit changes the events to mimick the behavior from the original mixin.

Resolves mui#3818
tintin1343 pushed a commit to tintin1343/material-ui that referenced this pull request Apr 25, 2016
This fixes a regression that was introduced in mui#3360. The previous `click-awayable` mixin listened on `mouseup` and `touchend` events and the new `ClickAwayListener` was implemented to use `mousedown` and `touchstart` events. This commit changes the events to mimick the behavior from the original mixin.

Resolves mui#3818
@newoga newoga deleted the remove-click-awayable branch June 7, 2016 04:18
@zannager zannager added the core Infrastructure work going on behind the scenes label Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants