Here is my code:
.buttons {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
.button {
padding: 5px;
background-color: rgb(200, 200, 200);
}
<div class="buttons">
<div class="button">
One
</div>
<div class="button">
Two
</div>
<div class="button" tabindex="0" contenteditable="true" spellcheck="false">
Three
</div>
</div>
Now, if I click on the right side of the third button, not on the button anymore, just somewhere in the space on the right side, then still the third button gets activated. Why? This is so weird!
It happens only once!
And it helps to use inline-flex
instead, but I need flex
, and then it still happens if I click in the little space on the left side of the button to the next one.
2
Answers
I found a possible solution for you’re problem, what you could do, as you can see by the following example-fix, is that you move "contenteditable="true" spellcheck="false"" to your desired button instead of the flex-child itself, this will allow you to encapsulate the editable effect on the button to the button itself, instead of it’s parent, which would be triggered when the given user is clicking the div! (As you can tell, I added another div for the content of you’re "buttons, for this to work" )
Hopefully this solution does it for you!
Best regards!
Marcus A.
Very Simple Workaround
As @RokoC.Buljan noted in a comment, the problem appears to be a Chromium bug.
The simple workaround is to add a
<wpr>
tag after the last button. This Line Break Opportunity is essentially an empty element. Yet, you could also use a
non-breaking space entity, which works equally well.Test Snippet