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.

[v2] Click events not firing on elements of custom Menu

See original GitHub issue

First of all, thanks for this great component. I’ve run into the following issue: I need to add a button as part of the select Menu, but the click events are not firing.

Sandbox example: https://codesandbox.io/s/jz0r9nln69

Code:

const Menu = props => {
  return (
    <React.Fragment>
      <button onClick={() => alert("clicked")}>
        Click me and nothing will happen
      </button>
      <components.Menu {...props}>{props.children}</components.Menu>
    </React.Fragment>
  );
};

export default class SingleSelect extends Component<*, State> {
  render() {
    return (
      <Select
        className="basic-single"
        classNamePrefix="select"
        name="color"
        options={colourOptions}
        components={{ Menu }}
      />
    );
  }
}

Stopping the propagation of the event doesn’t seem to help.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
asthajncommented, Mar 20, 2019

Hi @giuband , I am trying to have focus on an input in the menu. Not happening. How did you customize for your issue? Maybe that’ll give me some hint

<components.Menu {...props}> <input placeholder="Input test" />{props.children} </components.Menu>

2reactions
vidur149commented, Aug 23, 2018

How to stop firing of close menu when select is blurred. I want to somehow modify the logic of onBlur event. I also tried implementing a custom menu and it closes because onBlur is triggered.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JQuery click event not working on links with # - need to show ...
I need to show / hide the submenus on click on mobile. So nothing happens when Item 1 is clicked but item 2...
Read more >
Click event not firing after perform click menu item
I Unable to perform click the "Exit" menus on the image above. It only highlights the button upon testing the perform click, but...
Read more >
Firing Events - Testing Library
Convenience methods for firing DOM events. Check out src/event-map.js for a full list as well as default eventProperties .
Read more >
Context Menu click event not firing for custom ... - Syncfusion
Hi there, I'm having a small issue with a custom context menu on a grid. Try as I might, I cannot seem to...
Read more >
How to trigger a click() event on LWC element
Same thing I tried to do on the LWC element but it is not working. Template code [HTML] <template> <div class="standerdRelatedListCustom"> <div ...
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