Navigation items not clickable after window onclick event checker
See original GitHub issueMaking 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:
- Created 4 years ago
- Comments:10 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I had a similar problem too. Switching from display: block/none to visibly: visible/hidden fixed it for me
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.