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.

Navigation items not clickable after window onclick event checker

See original GitHub issue

Making the emoji picker into a modal has created some funky bugs. I am not really sure another way to target the picker other than through the event path, using the window click event. I got everything to work, except for the navigation items are now disabled when I run the window event checker.

I have tried several ways of running the for loop, including breaking out of it, but nothing seems to work.

    return (
        <div className="emoji-picker">
            <Picker className="emoji-picker" set='emojione' style={{ zIndex: 1,
                  position: "absolute",
                  top: "230px",
                  left: "34%" }}/>
        </div>
    )
}

 {emojiClick &&
              <div
                style={{
                  zIndex: 1
                }}
              ><EmojiPicker />
              </div>}

  useEffect(() => {
    window.onclick = e => {
      var classNameArray = [];
      if (e.target.className.baseVal === "create-post-icon smile-icon") {
        {
          setEmojiClick(!emojiClick);
        }
      } else {
        for (let i = 0; i < e.path.length; i++) {
          if (e.path[i].className === "emoji-picker") {
            classNameArray.push("match");
          } else {
            null;
          }
          if (classNameArray.length > 0) {
            setEmojiClick(true);
          } else {
            setEmojiClick(false);
            classNameArray = [];
          }
        }
      }
    };
  });```

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
mlshvcommented, Nov 19, 2020

I had a similar problem too. Switching from display: block/none to visibly: visible/hidden fixed it for me

2reactions
panalgincommented, Feb 12, 2020

I somewhat have a similar problem too, upon using emoji-mart inside a modal container, my navigation items are no-longer clickable until I manually click one of the emojis in the scrolled-container. This happens only at the first time the component supposed to be mounted. And the problem happens after an full-refresh (f5) has happened.

Read more comments on GitHub >

github_iconTop Results From Across the Web

icon not clickable with onclick event - Stack Overflow
Short answer: Try using element.closest() instead of element.matches() . I suspect it's the condition in your if statement.
Read more >
When a Click is Not Just a Click | CSS-Tricks
Clicks events are fired as a single event for clicking on the label and two events if you click on the checkbox. The...
Read more >
Handling Events :: Eloquent JavaScript
Event listeners are called only when the event happens in the context of the object they are registered on. <button>Click me</button> <p>No handler...
Read more >
JavaScript - Bootstrap
Bootstrap, a sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
Read more >
Buttons - Android Developers
To define the click event handler for a button, add the android:onClick attribute to the <Button> element in your XML layout.
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