-
Notifications
You must be signed in to change notification settings - Fork 141
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
Disable tethering while tooltips are hidden #96
Disable tethering while tooltips are hidden #96
Conversation
I can't figure out why the build is failing, but it also fails for master when I run it locally. I don't think it's related to this PR. |
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.
good fix
@@ -336,6 +338,10 @@ export default EmberTetherComponent.extend({ | |||
} | |||
|
|||
this.set('offset', offset); | |||
|
|||
if (event !== 'none' || this.get('tooltipIsVisible') !== true) { |
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.
nit: !this.get('tooltipIsVisible')
@@ -430,6 +440,16 @@ export default EmberTetherComponent.extend({ | |||
this.sendAction('onTooltipShow', this); | |||
}, | |||
|
|||
stopTether() { | |||
run.schedule('afterRender', this, function() { |
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.
nit: if you use arrow functions you won't need to pass in this
run.schedule('afterRender', () => {
...
});
|
||
startTether() { | ||
this.get('_tether').enable(); | ||
}, |
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.
could you add tests to check that the tether is enabled when we expect it to be?
isTetherEnabled: computed.alias('_tether.enabled'),
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.
We copied your fix here at Zenefits and did this to get test coverage
https://github.com/zenefits/ember-tooltips/pull/21/files#diff-eafc17148ee89489b3d8098122b506e6R409
As Andrew said, this is a great fix. Good catch and thank you for putting in the time to issue the PR. I will wait until #94 has landed to merge this but the code looks good so I don't have any comment there. This will likely need a quick rebase to resolve the merge conflicts once #94 is merged onto master. |
@joukevandermaas I think this may be helpful. It has full test coverage. I don't know if what I did with an https://github.com/zenefits/ember-tooltips/compare/v2.0.0-zenefits.1...v2.0.0-zenefits.2 |
I see some refactoring happened in the meantime, while adding popovers. I hope to get this PR fixed up today or tomorrow if I can. |
Sounds great, Jouke! Let myself or @a15n know if you have any questions about the refactoring from popovers. |
I rebased, adapted the code and added some asserts to the visibility tests. I squashed too, so the 'old' code is no longer visible here. I don't know why the beta build fails, but it doesn't look like it's anything to do with this PR. |
@@ -1,6 +1,6 @@ | |||
import Ember from 'ember'; | |||
import { moduleForComponent, test } from 'ember-qunit'; | |||
import { assertHide, assertShow } from '../../helpers/sync/assert-visibility'; | |||
import { assertHide, assertShow, assertTetherEnabled, assertTetherDisabled } from '../../helpers/sync/assert-visibility'; |
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.
I would recommend against creating a new assertion just for the tether. This means that people will always have to opt in to the coverage and will likely skip that test. Instead I would add the check as part of assertShow and assertHide. When I did this I found some holes in my enable/disable coverage
https://github.com/zenefits/ember-tooltips/pull/21/files#diff-c2e9fd979e3b24030663b2c4c84cd5beR3
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.
I think this should be blocking
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.
Yeah, good point. I'll try split it (or make a new PR if you want to merge already).
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.
If you could do it as part of this PR that'd be great. Thanks!
@@ -419,4 +435,20 @@ export default EmberTetherComponent.extend({ | |||
this.sendAction('onDestroy', this); | |||
}, | |||
|
|||
startTether() { | |||
// can't depend on `_tether.enabled` because it's not an | |||
// Ember property (so won't trigger cp update when changed) |
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.
good note
the two test failures are expected and not related to these changes. @sir-dunxalot maybe we should make the |
Pretty keen to see this integrated with the main build. Currently have some extreme lag after adding tooltips to my Ember app. |
@a15n I moved the tethering assert into the existing helper. There was a slight complication, because for delayed tooltips the tethering should be enabled but the tooltip should remain hidden for a while. I added some flag to the helper now, but another potential solution is to split this specific scenario into a new helper. Let me know what you think. |
@joukevandermaas thanks for your work on this. When we did this for our local repo we didn't have to provide any additional parameters for the tests. I think that if you add the https://github.com/zenefits/ember-tooltips/pull/21/files#diff-eafc17148ee89489b3d8098122b506e6R382 |
Good point, I've updated the code to do that and the special assert is no longer needed. Thanks! |
Great work @joukevandermaas! This code LGTM. |
+1. I will merge this, move Great work all. |
Released as |
This was causing performance issues on pages with many tooltips, because each repositioning triggered a forced reflow (which is expensive in most browsers, but especially in IE).