Fix: Check node supports selectionEnd before calling it
Issue
Email input type doesn't support selectionEnd which is used to clear off selection and errors on that call. More details can be found in #1853.

Solution
Check if node supports selectionEnd before calling it
Hi @PetroSilenius, thanks for pr but the issue is not fully resolved as I can see.
we are using selectionEnd as well as selectionStart at multiple locations which will eventually cause the same issue.
can you add a function to check if the input is supported and do nothing if not?
it's due to the following reason

Hey and thanks for taking a look at this! You're right that this PR doesn't fully solve the issue. I'll go ahead and a function for checking if a input supports selection and use that in places where it's needed
@robonetphy updated the PR to add a function for checking whether given node supports selection or not. Also added a check with that function in places where I saw either selectionStart or selectionEnd being used
What do you think of these changes?
@PetroSilenius Pls do these changes update the
changelog.mdand we are ready
Sure! Just double-checking that has it been decided not to support textarea in editor.js? They reason I included a check for it is that it also supports selectionStart and selectionEnd according to mdn docs
@PetroSilenius Pls do these changes update the
changelog.mdand we are readySure! Just double-checking that has it been decided not to support textarea in editor.js? They reason I included a check for it is that it also supports
selectionStartandselectionEndaccording to mdn docs
@PetroSilenius you are correct textarea also support both selectionStart and selectionEnd but comparison of tagName must be with the capital letter TEXTAREA as mdn docs or you can also add inside supported type as textarea both the ways are acceptable
@PetroSilenius you are correct
textareaalso support bothselectionStartandselectionEndbut comparison oftagNamemust be with the capital letterTEXTAREAas mdn docs or you can also add insidesupported typeastextareaboth the ways are acceptable
Right, thanks for catching the lowercase mistake! That's now fixed and updated the changelog as well as package version
If there something I could do still related to this PR, or are these change ready to be merged?😄 Last tests/edge run failed because of connetion issues when fetching packages. I think a simple rerun would fix it but don't have access to do that
Hi @PetroSilenius!
We are going to include this PR in one of the upcoming releases. At the moment we are trying to test it properly, so that there won't be any unexpected bugs.
As for deb240e, there was an error after attempt to set caret to input of unsupported type: Uncaught TypeError: Cannot read properties of undefined (reading 'top'), and that is the fix
Cool to hear! And thanks for taking care of the bug! I might have been a bit too easy on the testing after the newer changes so I didn't catch that😄
Please, cover the change with tests
Please, cover the change with tests
Added some test cases now, let me know if there's anything to improve in them!