editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

Fix: Check node supports selectionEnd before calling it

Open PetroSilenius opened this issue 4 years ago • 7 comments

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.

Screenshot of error

Solution

Check if node supports selectionEnd before calling it

PetroSilenius avatar Dec 31 '21 08:12 PetroSilenius

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 image

robonetphy avatar Apr 13 '22 17:04 robonetphy

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

PetroSilenius avatar Apr 13 '22 19:04 PetroSilenius

@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 avatar Apr 13 '22 19:04 PetroSilenius

@PetroSilenius Pls do these changes update the changelog.md and 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 avatar Apr 19 '22 19:04 PetroSilenius

@PetroSilenius Pls do these changes update the changelog.md and 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 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

robonetphy avatar Apr 20 '22 16:04 robonetphy

@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

Right, thanks for catching the lowercase mistake! That's now fixed and updated the changelog as well as package version

PetroSilenius avatar Apr 22 '22 06:04 PetroSilenius

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

PetroSilenius avatar Sep 20 '22 16:09 PetroSilenius

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

image

TatianaFomina avatar Nov 27 '22 20:11 TatianaFomina

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😄

PetroSilenius avatar Nov 27 '22 21:11 PetroSilenius

Please, cover the change with tests

neSpecc avatar Feb 18 '23 02:02 neSpecc

Please, cover the change with tests

Added some test cases now, let me know if there's anything to improve in them!

PetroSilenius avatar Feb 25 '23 16:02 PetroSilenius