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

ember-popovers #92

Merged
merged 39 commits into from
Oct 5, 2016
Merged

ember-popovers #92

merged 39 commits into from
Oct 5, 2016

Conversation

a15n
Copy link
Contributor

@a15n a15n commented Aug 29, 2016

ember-popovers

popovers

This PR addresses the need for a popover expressed here (#77) and implied here (#51)

  • creates popover-on-element and popover-on-component components which extend their tooltip counterparts
    • these all have the same API options as ember tooltips
    • these behave the exact same way EXCEPT
      • event handling is custom and mirrors that found in Twitter popovers.
      • a new hideDelay param which defines the milliseconds a user may hover outside of the popover before it hides. This is necessary because popovers can be spaced N pixels away from their target element
      • popovers have no visual CSS properties. These must be defined by the user
  • adds popover specific tests in the tests/integration/components/popover/ directory
  • exposes a hide action for use within the popover's block (ie clicking an interior close button)

Exhaustive list of changes made to tooltip-on-element

  • git mv tooltip-on-element.js tooltip-and-popover.js (c5da8b7)
  • moved the tooltip-specific event handling into tooltip-on-element's didInsertElement (2b99f85)
  • use classPrefix instead of one-off strings. Change classPrefix to tooltip-and-popover (9dc2fc7)
  • used classPrefix: 'ember-tooltip-or-popover', (1e9cef2 and 5045c4c)
  • deprecated tooltipIsVisible in favor of isShown (110c0fa)
  • deprecated onTooltipShow in favor of onShow, etc (5993997)
  • replaced tooltipCounterId with tooltipOrPopoverCounterId (26fcdd4)

Popover event="click"

  • clicking the target element will toggle the popover
  • clicking inside the popover will not toggle it
  • clicking outside of the target and the popover will hide it
    popover-click

Popover event="hover" (not suitable for mobile)

  • hovering on the target element will show the popover
  • hovering away from the target element will hide the popover after hideDelay milliseconds (default 250)
  • hovering from the target element to the popover works if it happens during the hideDelay
    popover-hover

Popover focus (available when event="focus", "click", or "hover"

  • focusing into the target will show the popover
  • focusing into the popover will keep the popover visible
  • focusing out of the popover and target will hide the popover
    popover-focus

Popover hide API

  • invoke the popover like so and gain access to the hide action
{{#popover-on-element as |popover|}}
    Click <a href {{action popover.hide}}>here</a> to hide popover
{{/popover-on-element}}

popover-hide

TODO (Blocking)

  • simplify the didInsertElement _showOn/_hideOn functionality if possible
  • rename tooltip-and-popover.tooltipIsVisible to isVisible
  • document all any differences in tooltip-and-popover made after the git mv
  • document how {{action popover.hide}} works and why the package.json changes were needed
  • fix display issue when effect="fade", spacing="0", event="hover"
  • fix display issue when effect="fade", spacing="0", event="click"
  • add gifs showing the interaction
  • get feedback on appropriate show/hide interactions to include/exclude, and write comprehensive tests for them
  • add event='focus' handling
  • get tests passing in separate PR first
  • confirm the correct class name paradigm (currently tooltip-and-popover, ember-tooltip, and ember-popover)
  • replace tooltipIsVisible with something more generic (not isVisible, maybe isShown or visible)

@a15n
Copy link
Contributor Author

a15n commented Aug 29, 2016

even with the "initial commit" commit the tests are failing...

https://travis-ci.org/sir-dunxalot/ember-tooltips/jobs/156037676

@@ -0,0 +1,3 @@
{{yield (hash
hide=(action "hide")
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: indent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a github display issue. It is correctly indented in my IDE

"ember-cli-sass": "5.3.1"
"ember-cli-htmlbars": "^1.1.0",
"ember-cli-sass": "5.3.1",
"ember-hash-helper-polyfill": "^0.1.1"
Copy link
Contributor Author

@a15n a15n Aug 29, 2016

Choose a reason for hiding this comment

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

we need ember-hash-helper-polyfill and ember-cli-htmlbars because of the template that passes the hide closure action to the yield via the hash helper

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ember-hash-helper-polyfill is only needed till Ember 2.3

@sir-dunxalot
Copy link
Owner

Hey @a15n - any idea why the tests are failing on the initial commit? Could it be as simple as merging with master?

@a15n
Copy link
Contributor Author

a15n commented Aug 30, 2016

@sir-dunxalot I made sure to use the most up to date version before I started. I'm checking my git log and I have the 2.0.1 release and all the subsequent commits. When I run the tests locally I get the following errors. These are the same errors I noticed when I tested the 'initial commit'.

screen shot 2016-08-30 at 9 33 12 am

screen shot 2016-08-30 at 9 32 59 am

screen shot 2016-08-30 at 9 33 24 am

Died on test #2     at testWrapper (http://localhost:4200/assets/test-support.js:6996:11)
at test (http://localhost:4200/assets/test-support.js:7010:39)
at Module.callback (http://localhost:4200/assets/tests.js:2217:24)
at Module.exports (http://localhost:4200/assets/vendor.js:132:32)
at requireModule (http://localhost:4200/assets/vendor.js:32:18)
at s (http://localhost:4200/assets/vendor.js:67058:143)
at s (http://localhost:4200/assets/vendor.js:67058:123): Cannot read property 'classList' of null

@a15n
Copy link
Contributor Author

a15n commented Aug 30, 2016

Also...

screen shot 2016-08-30 at 9 36 22 am

@sir-dunxalot
Copy link
Owner

Hmm, ok. I think either you or I will have to work on this branch and get it passing before merging in. With a PR this big I'd rather not merge onto master and then get things to pass (incase others are pulling down master into their projects directly). I could pull down from your branch if preferred.

Alternatively, we could reissue this PR to a popover branch on this repo and I could try and get the tests to pass on that before merging it into master.

Let me know how you would like to proceed. I know you've done tons of work on this so I don't want to have you to put in more work especially if it's unrelated to this feature.

@a15n
Copy link
Contributor Author

a15n commented Aug 30, 2016

"With a PR this big I'd rather not merge onto master and then get things to pass (incase others are pulling down master into their projects directly)"

Agreed. If you were able to pull down this branch and investigate that would be great. There are popover tests failing right now but I am in the process of fixing those.

Thanks

@a15n
Copy link
Contributor Author

a15n commented Aug 30, 2016

@sir-dunxalot regarding class name structure I have .ember-tooltip (no changes), .ember-popover, and .tooltip-and-popover for the CSS attributes that are shared by both. What do you think would be best?

@@ -40,25 +40,28 @@ export default TooltipAndPopoverComponent.extend({

} else if (_showOn === 'click') {

$target.on(_showOn, (event) => {
$(document).on('click', (event) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets make sure you unsubscribe from all events, but specially this one.

return;
}

if (_showOn === 'mouseenter') {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'll be able to simplify the _showOn == 'mouseenter' case now that I only use _isMouseInside for that approach.

@a15n
Copy link
Contributor Author

a15n commented Sep 6, 2016

Yes the code portion is all set now. Things have gotten rather busy for me at work so I don't think I'll be able to help with updating the resources.

We are good to wait till this weekend. Thanks!

@sir-dunxalot
Copy link
Owner

Ok, great. I'll wait to merge this in until I have the documentation in place. I don't mind a 10-minute overlap of merging without the docs updated so I'll do it on the fly. I'll also do a QA run through - will keep you updated.

@jamesdixon
Copy link

Well done, gents! Looking forward to trying this out.

@andrew-zenefits
Copy link
Contributor

@sir-dunxalot you'll notice in this latest PR that I have improved the jQuery checks to determine if an element is inside the popover or elsewhere. I tested out the new popovers in our code base and learned that sometimes all of the tethers are contained within a div at the bottom, rather than within the target. For this reason the following code didn't work and this fix was necessary..

$target.find(clickedElement).length;
// didn't work because sometimes the popover was outside of the target

3248b18

hideDelay: '250',

layout,
classNames: ['ember-popover'],
Copy link

@jliuzen jliuzen Sep 7, 2016

Choose a reason for hiding this comment

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

nit/personal preference: put classNames at top (above hideDelay)

@andrew-zenefits
Copy link
Contributor

andrew-zenefits commented Sep 8, 2016

@sir-dunxalot, @MiguelMadero you'll notice in the last commit I've triggered every event='focus' test event with javascript instead of jQuery. While investigating the flaky event='focus' tests we discovered that each test would fail the second time it was called, unless the chrome screen was clicked just before the test was run. We suspected that the trigger('focus') events weren't being triggered correctly the second time. Miguel mentioned something about synthetic events being introduced in Ember 2.8. We think that Travis is being affected by the same thing.

ff262b6

@jamesdixon
Copy link

How's this going guys? Anxious to give it a shot!

@andrew-zenefits
Copy link
Contributor

@sir-dunxalot is there anything I can do to help this land?

@sir-dunxalot
Copy link
Owner

Hey Andrew, it's honestly just documentation in the README. I've worked 14 days straight and still haven't gotten to it. My apologies. Let me know if you're able to push this over the line.

@a15n
Copy link
Contributor Author

a15n commented Sep 29, 2016

@sir-dunxalot I'm glad I was able to work on this some more. I added backwards compatibility for tooltipIsVisible and the onTooltipShow, etc parameters. I have added tests to support these properties. I recommend we plan on removing support for these properties in v3.0.0.

I have also updated the readme to include popovers.

I believe this is ready to merge, BUT it still has flaky tests in ember-beta. I'm at a loss for how to address the flaky tests because I cannot get them to fail locally.

@a15n
Copy link
Contributor Author

a15n commented Oct 3, 2016

@sir-dunxalot I've addressed some of the failing tests here. #97

Let me know if I can help in any other way to land this.

@sir-dunxalot
Copy link
Owner

sir-dunxalot commented Oct 5, 2016

Andrew, I'm finally getting around to this. This has been an immense effort - great work, truly.

#97 is now on master. It looks like that has caused merge conflicts. If we can fix those so that there's only the one test failure (the el.classList is not an object error) then I'm happy to merge this, fix that one test locally, and release.

@a15n
Copy link
Contributor Author

a15n commented Oct 5, 2016

@sir-dunxalot I have merged with the newest master, resolved conflicts, and all tests are passing except the Integration | Component | tooltip on component tests on ember-beta and ember-canary. I think we're good to go?

@sir-dunxalot
Copy link
Owner

Alright, I'm merging and pulling down now. I will try and get those last two test passing before releasing.

@sir-dunxalot sir-dunxalot merged commit 0171fbf into sir-dunxalot:master Oct 5, 2016
@sir-dunxalot
Copy link
Owner

I've got four tests failing locally with the following error:

'[object EventConstructor]' is not a constructor (evaluating 'new window.Event('focus')')

I'm attempting to fix these before fixing the remaining two tooltip on component failing tests.

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.

7 participants