Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-text inputs can trigger exception inside isTextField in Safari #8254

Closed
chrisvanpatten opened this issue Jul 27, 2018 · 0 comments · Fixed by #8255
Closed

Non-text inputs can trigger exception inside isTextField in Safari #8254

chrisvanpatten opened this issue Jul 27, 2018 · 0 comments · Fixed by #8255
Labels
Browser Issues Issues or PRs that are related to browser specific problems [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Enhancement A suggestion for improvement.

Comments

@chrisvanpatten
Copy link
Contributor

chrisvanpatten commented Jul 27, 2018

Describe the bug
When a block exists with a non-text <input> (e.g. <input type="submit"> it can cause an issue inside isTextField.

This seems to be specific to Safari, which throws an exception when trying to get selectionStart from a non-text <input>. Other browsers return undefined (such as Chrome) but Safari throws a TypeError exception for whatever reason.

isTextField@http://redacted/content/plugins/gutenberg/build/dom/index.js?ver=1532620128:2539:31
filter@[native code]
focusTabbable@http://redacted/content/plugins/gutenberg/build/editor/index.js?ver=1532620128:2230:109
componentDidMount@http://redacted/content/plugins/gutenberg/build/editor/index.js?ver=1532620128:2178:27
commitLifeCycles@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:14939:39
commitAllLifeCycles@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:16040:23
callCallback@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:140:19
dispatchEvent@[native code]
invokeGuardedCallbackDev@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:178:29
invokeGuardedCallback@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:227:34
commitRoot@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:16181:30
completeRoot@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:17196:44
performWorkOnRoot@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:17141:21
performWork@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:17060:24
performSyncWork@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:17032:14
interactiveUpdates$1@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:17297:22
dispatchInteractiveEvent@http://redacted/content/plugins/gutenberg/vendor/react-dom.24169eaf.js:4882:21
dispatchInteractiveEvent@[native code]

To Reproduce
Steps to reproduce the behavior:

  1. Register a block type with an <input type="submit"> inside the Edit representation
  2. Insert the block
  3. Get the above error

Expected behavior
No error should be displayed.

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Safari 11.1.1
  • Gutenberg Version: master
@chrisvanpatten chrisvanpatten changed the title Non-text inputs inside a block's edit representation can cause isTextField issues Non-text inputs can trigger isTextField errors in Safari Jul 27, 2018
@chrisvanpatten chrisvanpatten changed the title Non-text inputs can trigger isTextField errors in Safari Non-text inputs can trigger exception inside isTextField in Safari Jul 27, 2018
@designsimply designsimply added [Type] Enhancement A suggestion for improvement. Browser Issues Issues or PRs that are related to browser specific problems [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... labels Jul 27, 2018
chrisvanpatten added a commit that referenced this issue Oct 18, 2018
* Catch a Text Selection Exception in Safari; fixes #8254

* Improve the inline explanation of why we need a try/catch block
antpb pushed a commit to antpb/gutenberg that referenced this issue Oct 26, 2018
* Catch a Text Selection Exception in Safari; fixes WordPress#8254

* Improve the inline explanation of why we need a try/catch block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Browser Issues Issues or PRs that are related to browser specific problems [Feature] Writing Flow Block selection, navigation, splitting, merging, deletion... [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants