palantir/blueprint

Enabled anchor buttons don't trigger the onClick callback if the button is immediately disabled after being clicked. Buttons do.

Open

#5,245 建立於 2022年4月7日

在 GitHub 查看
 (0 留言) (0 反應) (0 負責人)TypeScript (20,263 star) (2,167 fork)batch import
P3Package: coreType: bughelp wanted

描述

Environment

  • Package version(s):
  • Operating System:
  • Browser name and version:

Code Sandbox

I have a button that I only want to be enabled when a certain element has focus. When the user clicks the button, that element will no longer have focus so the button will no longer be enabled, but I want the initial click to go through and trigger the onClick callback. I am seeing this work with <Button /> but not <AnchorButton />. It'd be nice if when I clicked an enabled anchor button, the onClick callback went through even if I immediately disable the button. I can't just use a Button instead because I also want to show a tooltip on the disabled button which AnchorButtons are recommended for.

Bug report Package version(s): Browser and OS versions:

Expected behavior When I click an enabled button, the callback is run

Steps to reproduce

  1. Have an anchor button that is disabled when a given element doesn't have focus and has an onclick callback

  2. Click the button

  3. The callback isn't run

  4. Repeat the above with a normal Button

  5. The callback is run

Actual behavior

If I click a button while it's enabled and then immediately disabled it, the callback isn't run

Expected behavior

When I click an enabled button, the callback is run

Possible solution

貢獻者指南

Enabled anchor buttons don't trigger the onClick callback if the button is immediately disabled after being clicked. Buttons do. · palantir/blueprint#5245 | Good First Issue