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

improve hover behavior, simplify interface, and improve readme #68

Merged

Conversation

gkchestertron
Copy link
Contributor

@gkchestertron gkchestertron commented Dec 22, 2017

This project uses semver, please check the scope of this pr:

  • #none# - documentation fixes and/or test additions
  • #patch# - backwards-compatible bug fix
  • #minor# - adding functionality in a backwards-compatible manner
  • #major# - incompatible API change

CHANGELOG

  • removed includeContentsInEvents flag
  • added handlers for hovering over popover when visible
  • add hideDelay to readme and alphabetize options

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling a44778b on gkchestertron:improve-popover-hover into ** on ciena-frost:master**.

README.md Outdated

## Specifying Target

If the `frost-popover` component is placed next to the `target`, be careful to use a selector that will uniquely
identify the `target`. If it is nested inside the `target`, you can set `closest` to true which will search the
nearest ancestor from the `popover`.
nearest ancestor from the `popover` - which is far more performant than a full dom traversal.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment is needless in my opinion. Unless we're talking about huge perf gains, comments like these sound like marketing BS. It'll also bias our users to always using the nested version which is not what I want. I'm actually a fan of the sibling approach as the positioning is much more predictable. The nested version has it's merits and it's the only way to have unique popovers for arrays of similar items.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those kinds of traversals can become real problems - but I suppose here they can only be kicked off as fast as a user can hover their mouse. And, I agree - I like the sibling approach better. The includeContentInEvents flag didn't work with the sibling approach, which is what led me to needing to work on this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Most of jQuery can become real problems :) In a majority of cases, I try not to optimize unless I know the code is running "hot" or executed many times. Since the popover getTarget didn't meet that criteria, it wasn't a cause of concern for me and so not a concern I want to inform users about.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair enough

@@ -22,7 +22,6 @@ export default Component.extend(PropTypeMixin, {
excludePadding: PropTypes.bool,
handlerIn: PropTypes.string,
handlerOut: PropTypes.string,
includeContentInEvents: PropTypes.bool, // making this true lets the content also inheret events properly
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reason for removing this. Wouldn't it be considered a #MAJOR# if you removed a feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, normally yes. But this was added just for one feature in mcp recently, and was not documented. So, no one else is using it, and now mcp isn't either. And the functionality is brought forward - but you can't turn it off. If we feel this should be behind a flag, we can do that, but it prob shouldn't be called this. And I don't think it should be something you can turn off - when would you specifically not want to be able to hover/select the text in a popover?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think @EWhite613 may have added this? Even if this flag isn't used in MCP, it might be used in other apps. Let's be on the safe side and make this a #MAJOR#.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@@ -142,6 +143,21 @@ export default Component.extend(PropTypeMixin, {

$(target).on(event, this._eventHandler)
}

// handle mouse events on visible popover
$(popover).on('mouseenter', event => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a good idea to use off when the component dies. Even if popover is destroyed when the component dies, the event listeners are still attached due to how Ember destroys the DOM.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Umm... yes. A really good idea. Thank you.

@@ -164,11 +180,7 @@ export default Component.extend(PropTypeMixin, {
* @param {DOMEvent} event - click event
*/
togglePopover (event) {
const popover = this.get('element')
if ($(event.target).closest(popover).length === 0 ||
Copy link
Contributor

Choose a reason for hiding this comment

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

So does this remove the ability to have a sustained popup and clicking on the outside to close it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Crap - yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, no - this still works because I am blocking the click on the content from propagating. But, what does happen is that if the popover is meant to work on click and you hover over it - it will now close on mouseleave.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 92b7f48 on gkchestertron:improve-popover-hover into ** on ciena-frost:master**.

@cstolli
Copy link

cstolli commented Jan 2, 2018

👍

Approved with PullApprove

@gkchestertron gkchestertron merged commit e78e22d into ciena-frost:master Jan 2, 2018
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.

None yet

4 participants