I have an editable content div, that a user adds elements to. The user has a side menu with all the available tags that can be added by click on each tag. It is also possible to type in text before/after each tag.
Each tag element has contenteditable="false", for example:
.keyword-item {
background-color: #EEFDE5;
font-weight: bold;
border-radius: 20px;
border: unset;
cursor: pointer;
margin: 0 0.25rem 0 0.25rem;
}
img {
padding-left: 2%;
}
span {
padding-right: 2%;
}
<div contenteditable="true" id="expression-textarea">
<label class="keyword-item" contenteditable="false">
<input type="hidden" value="1">
<img src="https://img.icons8.com/small/16/000000/download-2.png"/>
<span>bla</span>
</label>
<label class="keyword-item" contenteditable="false">
<input type="hidden" value="2">
<img src="https://img.icons8.com/small/16/000000/download-2.png"/>
<span>bla bla 2</span>
</label>
<label class="keyword-item" contenteditable="false">
<input type="hidden" value="18">
<img src="https://img.icons8.com/small/16/000000/download-2.png"/>
<span>bla2</span>
</label>
</div>
Two problems with this (with Chrome at least):
- When I'm using the keyboard arrows to navigate around those items, it works well. However, mouse navigation is a little bizzare; It seems impossible to get the cursor between the second and the third icon.
- The first item is being deleted only by focusing in front of it and pressing the
DELkey, it doesn't delete by focusing after it and pressing backspace.
Thanks in advance