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
[feature] disabled
attribute
#120
Conversation
Only thing I'm not sure about is not showing the tooltip if |
So I added LTS targets and those all pass along with 1.13, but delay is still broken with 2.10. This feature should still be mergeable, since this test failure is unrelated. |
@a15n I don't want to merge this without a review from you given to the effects of this on |
@@ -93,7 +94,7 @@ export default Ember.Component.extend({ | |||
enableLazyRendering: false, | |||
_hasUserInteracted: false, | |||
_hasRendered: false, | |||
_shouldRender: computed('isShown', 'tooltipIsVisible', 'enableLazyRendering', '_hasUserInteracted', function() { | |||
_shouldRender: computed('isShown', 'disabled', 'tooltipIsVisible', 'enableLazyRendering', '_hasUserInteracted', 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.
let's move disabled
to be the first property. It is the most important.
@@ -93,7 +94,7 @@ export default Ember.Component.extend({ | |||
enableLazyRendering: false, | |||
_hasUserInteracted: false, | |||
_hasRendered: false, | |||
_shouldRender: computed('isShown', 'tooltipIsVisible', 'enableLazyRendering', '_hasUserInteracted', function() { | |||
_shouldRender: computed('isShown', 'disabled', 'tooltipIsVisible', 'enableLazyRendering', '_hasUserInteracted', function() { | |||
// if isShown, tooltipIsVisible, !enableLazyRendering, or _hasUserInteracted then |
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.
can you add disabled
to this note as well
@@ -102,7 +103,7 @@ export default Ember.Component.extend({ | |||
|
|||
return true; | |||
|
|||
} else if (this.get('isShown') || this.get('tooltipIsVisible')) { | |||
} else if (!this.get('disabled') && (this.get('isShown') || this.get('tooltipIsVisible'))) { | |||
|
|||
this.set('_hasRendered', true); | |||
return 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.
I can't comment below this line so see lines....
111: what if enableLazyRendering=false
and disabled=true
?
129: what if enableLazyRendering=false
but _shouldRender=false
? The didInsertElement will still apply $parent event handling and could still render the tooltip, even if it's never shown (not clean)
If these happen to be edge cases you missed can you add tests for them?
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.
should I just handle disabled
once before all of these conditionals, and return false
?
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.
And what about in 128, if i skip the parent event stuff, and then disabled gets set to false, would that be rerun anywhere else?
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.
"should I just handle disabled once before all of these conditionals, and return false?"
I think if you add this it'll take care of _shouldRender
if (this.get('_hasRendered')) {
return true; // this always needs to return true if it has ever been rendered
} else if (isDisabled) {
return false;
....
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.
"And what about in 128, if i skip the parent event stuff, and then disabled gets set to false, would that be rerun anywhere else?"
You're right. If we people change isDisabled we would need to add the event listeners to the $parent. I think maybe we should make the $parent event handling a function that can be called on didInsertElement and by observing isDisabled
.
We'd need good tests to cover this. It's getting fairly complex
So the You can achieve the "no show" behavior if you set I'm a little hesitant to introduce this because there are existing ways to get the same behavior and with more options comes more complexity. From a technical point of view this PR looks good though. Can you explain a little more about why a |
@aaminev would this be useful in the scenario when there is no tooltip text? You could do something like...
This way you could disable a tooltip by explicitly depending on the length of the string. |
@knownasilya also thanks for your work to add LTS support! I definitely think that's a great idea but I think it should be done in a separate PR. And also I'd prefer that we keep master green so we'd need to add 2.1.0 to the list of allow_failures until the delay test is fixed. |
Maybe this is too big of a feature for something that could be replaced by a wrapper.. e.g. {{#desktop-tooltip}}
My Text
{{/desktop-tooltip}} which just wraps the tooltip in an |
Agreed, I think the ideal way would be to create you're own wrapper. |
Another solution could be to set |
@sir-dunxalot so change it to
My code looks like so: desktop-tooltip.hbs {{#unless media.isMobile}}
{{#tooltip-on-element side=side delay=delay duration=duration}}
{{yield}}
{{/tooltip-on-element}}
{{/unless}} desktop-tooltip.js import Ember from 'ember';
export default Ember.Component.extend({
tagName: '',
side: 'bottom',
delay: 750
}); The error occurs when |
Related issue: yapplabs/ember-tether#35 so this doesn't work with 2.10 if you put it in an |
So the workaround for that would be to wrap |
@knownasilya was this thread continued anywhere else or is it not addressed? I see yapplabs/ember-tether#35 is still open which is blocking the upgrade to 2.11 at the moment |
It hasn't continued. Basically, I did a wrapper component like so: {{#unless media.isMobile}}
<div>
{{#tooltip-on-element side=side delay=delay duration=duration}}
{{yield}}
{{/tooltip-on-element}}
</div>
{{/unless}} |
@knownasilya did you have a solution for |
I didn't have that requirement. I think this PR would have to be completed to support that. |
Allows a
disabled
attribute to prevent showing the tooltip by any of the available methods:Talked about this with @sir-dunxalot on Slack.