ashlsun / untitled-inventory-app

0 stars 0 forks source link

Prevent cursor insertion when clicking outside of the item name span #4

Closed ashlsun closed 1 week ago

ashlsun commented 1 week ago

Clicking on an item with the cursor closer to the item name than the item age (i.e. the text reading 1d, 3mos, etc) will insert the caret at the end of the item name. I would expect that a caret is inserted only when clicking directly on the item name.

This seems to happen because I'm using a contenteditable span instead of an input, which I chose because it automatically resizes to fit the length of the value inside it.

This answer is helpful, but following the suggestion (to make a parent display: inline-block) hasn't solved the problem for me. https://stackoverflow.com/questions/24345805/prevent-contenteditable-element-from-getting-focus-when-clicking-parent