Enabled anchor buttons don't trigger the onClick callback if the button is immediately disabled after being clicked. Buttons do.
#5245 opened on Apr 7, 2022
Description
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
-
Have an anchor button that is disabled when a given element doesn't have focus and has an onclick callback
-
Click the button
-
The callback isn't run
-
Repeat the above with a normal Button
-
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