简体   繁体   English

禁用按钮时,angular2-mdl工具提示被卡住

[英]angular2-mdl tooltip gets stuck when disabling button

I've set an mdl-tooltip on a button. 我在按钮上设置了mdl-tooltip。 When the mouse hovers over the button, tooltip is displayed correctly. 当鼠标悬停在按钮上时,将正确显示工具提示。 When the mouse leaves the button, tooltip disappears correctly. 当鼠标离开按钮时,工具提示会正确消失。

When button is clicked, button is disabled and the tooltip remains displayed. 单击按钮后,按钮将被禁用,并且工具提示仍会显示。 How do I fix this such that the tooltip is hidden when the button is clicked/disabled? 如何解决此问题,以便在单击/禁用按钮时隐藏工具提示?

<button type="button" mdl-button mdl-button-type="icon" mdl-colored="primary" mdl-ripple mdl-tooltip="Disable Button" mdl-tooltip-position="bottom" (click)="isDisabled = true" [disabled]="isDisabled">
    <mdl-icon>close</mdl-icon>
  </button>

plunker: http://plnkr.co/edit/vGw8W93jR0j6qzHCyASS?p=preview 塞子: http ://plnkr.co/edit/vGw8W93jR0j6qzHCyASS?p=preview

pointer events are not fired on disabled elements. 不会在禁用的元素上触发指针事件。 (have a look for a discussion on that topic: Event on a disabled input ) (请查看有关该主题的讨论: 禁用输入事件

you can change your code in this way to make possible what you are trying to do: 您可以通过这种方式更改代码,以使您可以尝试执行以下操作:

   <span mdl-tooltip="blah">
      <button mdl-button  mdl-button-type="fab" mdl-colored="primary" 
        [disabled]="itemDisabled" (click)="itemDisabled=!itemDisabled">
        <mdl-icon>add</mdl-icon>
      </button>
   </span>

(see also: https://github.com/mseemann/angular2-mdl/issues/535 ) (另请参阅: https : //github.com/mseemann/angular2-mdl/issues/535

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM