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

Disable tethering while tooltips are hidden #96

Merged
merged 3 commits into from
Oct 14, 2016
Merged

Disable tethering while tooltips are hidden #96

merged 3 commits into from
Oct 14, 2016

Conversation

joukevandermaas
Copy link
Contributor

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).

@joukevandermaas
Copy link
Contributor Author

joukevandermaas commented Sep 21, 2016

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.

Copy link
Contributor

@a15n a15n left a 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) {
Copy link
Contributor

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() {
Copy link
Contributor

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();
},
Copy link
Contributor

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'),

Copy link
Contributor

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

@sir-dunxalot
Copy link
Owner

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
Copy link
Contributor Author

OK, I'll address @a15n's comments and rebase after #94 is merged, then. Thanks!

@a15n
Copy link
Contributor

a15n commented Oct 10, 2016

@joukevandermaas I think this may be helpful. It has full test coverage. I don't know if what I did with an is-tether-enabled attribute is ideal. A 'js-' prefixed class may be better.

https://github.com/zenefits/ember-tooltips/compare/v2.0.0-zenefits.1...v2.0.0-zenefits.2

@joukevandermaas
Copy link
Contributor Author

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.

@sir-dunxalot
Copy link
Owner

Sounds great, Jouke! Let myself or @a15n know if you have any questions about the refactoring from popovers.

@joukevandermaas
Copy link
Contributor Author

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';
Copy link
Contributor

@a15n a15n Oct 12, 2016

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

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 this should be blocking

Copy link
Contributor Author

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).

Copy link
Contributor

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)
Copy link
Contributor

Choose a reason for hiding this comment

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

good note

@a15n
Copy link
Contributor

a15n commented Oct 12, 2016

the two test failures are expected and not related to these changes. @sir-dunxalot maybe we should make the ember-beta test failure allowable?

@lvl99
Copy link

lvl99 commented Oct 12, 2016

Pretty keen to see this integrated with the main build. Currently have some extreme lag after adding tooltips to my Ember app.

@sir-dunxalot sir-dunxalot mentioned this pull request Oct 12, 2016
@sir-dunxalot
Copy link
Owner

Yes, I think making ember-beta failure allowable is acceptable given the conversations about the impact of glimmer (see #97). As such, this PR should be good to go once @a15n 's code comments have been addressed.

@joukevandermaas
Copy link
Contributor Author

@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.

@a15n
Copy link
Contributor

a15n commented Oct 14, 2016

@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 startTether() call inside the if/else within the show function you won't need the additional test parameter or special handling.

https://github.com/zenefits/ember-tooltips/pull/21/files#diff-eafc17148ee89489b3d8098122b506e6R382

@joukevandermaas
Copy link
Contributor Author

Good point, I've updated the code to do that and the special assert is no longer needed. Thanks!

@a15n
Copy link
Contributor

a15n commented Oct 14, 2016

Great work @joukevandermaas! This code LGTM.

@sir-dunxalot ^

@sir-dunxalot
Copy link
Owner

+1. I will merge this, move ember-beta to allowed failures, and will release today with the passing test suite.

Great work all.

@sir-dunxalot sir-dunxalot merged commit 695dd16 into sir-dunxalot:master Oct 14, 2016
@sir-dunxalot
Copy link
Owner

sir-dunxalot commented Oct 14, 2016

Released as 2.3.1.

@joukevandermaas joukevandermaas deleted the disable-tether branch October 15, 2016 16:48
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.

5 participants