question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Button with endEnhancer onClick issue

See original GitHub issue

Current Behavior

I have a Button which has an endEnhancer, to show an icon. The button has an onClick event to update a state. If I click the button itself, then it will set the value of the Button no problem.

If I click the endEnhancer icon, then it will still run the onClick event from the button, but it the value will be undefined.

What is the correct use of this combo or is there a bug when using an endEnhancer? Should it not inherit the value of the button, if it inherits the onClick event?

Here’s a demo with an alert. Try clicking the button and precisely on the icon: https://codesandbox.io/s/button-with-endenhancer-doxgi

Expected Behavior

That clicking the button itself or the endEnhancer produces the same event / outcome.

Your Environment

Tech Version
Base UI v8.6.1
React 16.8.2
browser Chrome 75.x
  • I have searched the issues of this repository and believe that this is not a duplicate.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
sandgrahamcommented, Jul 17, 2019

This is how event capturing & bubbling works by default in the browser.

I don’t think we should change/hide this behavior. There may be legitimate use cases for allowing normal event capturing within an enhancer (a nested checkbox perhaps). The onClick still has context on which button was clicked so I don’t think this behavior limits folks. If you do need to grab something from the button element instance related to the event, you can always use the event object to grab the parent element or use a ref.

While I don’t think the actual event should be altered/hidden, the onChange handler itself might pass additional arguments that could be useful. We don’t have to only pass events.

0reactions
github-actions[bot]commented, Sep 13, 2019

This issue is stale because it has been open 30 days with no activity. If it’s still valid, please remove the stale label or comment on the issue, otherwise this ticket will be closed in 5 days

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with attaching onClick event to dynamically created ...
The issue is not with the pagination buttons but the buttons in the list items that fire all at once when clicked. Its...
Read more >
How to use the baseui/button.KIND.secondary function in baseui ...
To help you get started, we've selected a few baseui/button. ... Snyk Code to scan source code in minutes - no build needed...
Read more >
Cheat Sheet - Base Web
button -group · ButtonGroupProps · ariaLabel; children · disabled · mode · onClick · overrides · selected · shape · size · kind...
Read more >
trying to pass "id" onclick of a button in LWC [closed]
Questions about implementation problems need to include a specific description of the problem (including exact errors and stack traces, if any) ...
Read more >
@biossun/react-view - NPM Package Overview - Socket - Socket.dev
onClick : { value: '() => alert("click")', type: PropTypes.Function, description: 'Function called when button is clicked.', }, disabled: { value: false ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found