ashlsun / untitled-inventory-app

0 stars 0 forks source link

Prevent user from pasting characters beyond the 20 character max #25

Closed ashlsun closed 1 day ago

ashlsun commented 6 days ago

When editing an item name, the 20 char max for an item name is enforced by not allowing any keypress to go through if it's not a delete, backspace, or if its not at least replacing any characters (some text is selected). Users can still get around that by pasting more characters in than the limit should allow.

This might easily be solved if the item name input were a real <input> instead of a contenteditable <span>, but the span was chosen to make the input area resize according to the width of the content. If you can find a way to make it an <input> whose size always snugly fits to its contents, then go for it!

Image

edit: looks like i made a mistake and i either meant to make it a 18 character max, or am enforcing 18 but i meant to enforce 20

Rettend commented 5 days ago

two ideas:

not sure which is better overall