WordPress.org

Make WordPress Core

Opened 6 weeks ago

Closed 2 weeks ago

Last modified 2 weeks ago

#51577 closed defect (bug) (reported-upstream)

DOMException: Failed to set the 'selectionStart' property on 'HTMLInputElement'

Reported by: bradmarshall Owned by:
Milestone: Priority: normal
Severity: blocker Version: 5.5.1
Component: Editor Keywords:
Focuses: Cc:

Description

Actual behaviour:
dom.js is attempting to access the selectionStart property on input[type=email] in Gutenberg running WordPress 5.5.1, which triggers a DOM exception in the WP admin which breaks the gutenberg block containing the input.

Why?
This MDN article (https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange) states that only certain types of inputs and textareas impmlement selectionStart / selectionEnd but it looks as though numerous functions throughout the file attempt to use selectionStart/selectionEnd without first qualifying the type of input in question. Therefore, any input[type=email] elements in a block are crashing out.

Expected behaviour:
dom.js should not attempt to use selectionStart/selectionEnd on just any type of input - it should instead first check to make sure it's one of type=text, search, URL, tel or password. Gutenberg blocks containing input types other than these should not crash.

Change History (2)

#1 @sabernhardt
2 weeks ago

  • Component changed from General to Editor
  • Milestone Awaiting Review deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed

@bradmarshall Thanks for the report!

I moved this to GitHub for the Editor team to handle there.
https://github.com/WordPress/gutenberg/issues/26983

#2 @bradmarshall
2 weeks ago

Awesome, thanks very much! Will follow there.

Note: See TracTickets for help on using tickets.