Starcounter / DevTools

A browser extension that helps you debug Starcounter apps with ease
3 stars 1 forks source link

View-model edited field gets unfocused #31

Closed warpech closed 9 years ago

warpech commented 9 years ago

Using starcounter-debug-aid@a7e1a95 and Juicy/juicy-jsoneditor@91bf34e

In InvoiceDemo, editing Price# via starcounter-debug-aid updates Total as expected, but the Price$ input element gets unfocused after each keystroke.

miyconst commented 9 years ago

I take this one.

miyconst commented 9 years ago

This is a bit tricky.

After spending some time I was able to restore focus position and put cursor to the end of the field. jsoneditor uses <div contenteditable="true"></div> instead of inputs, that is why I can't use standard input/textarea api to get/set cursor position, window.getSelection should be used instead, but it does not work for elements inside shadow dom: http://stackoverflow.com/questions/23882272/contenteditable-in-shadow-dom.

The best way would be to apply changes on blur instead of mouseup, but this requires changes inside jsoneditor.

Anyway, I think that restoring focused element and setting cursor to the end of the text is enough for now.

warpech commented 9 years ago

Let's keep it like this. If someone has a problem with it, they can report a bug. Thanks!