Page MenuHomePhabricator

Uncaught TypeError: blockTargetWidget.getValue(...).trim is not a function in special.block.js
Closed, ResolvedPublic

Description

Background

Since T324602: SpecialBlock: Once a temporary account is selected, below the username field display IP addresses associated with the account the target widget on Special:Block is a UsersMultiselectWidget, with limit 1.

This means that calling getValue() on the widget now returns an array, rather than a string.

Loading Special:Block causes a JavaScript error: Uncaught TypeError: blockTargetWidget.getValue(...).trim is not a function, because this line is expecting getValue() to return a string:

https://gerrit.wikimedia.org/g/mediawiki/core/+/7715964706dd1a03e6dd272d8ae99781491b5b62/resources/src/mediawiki.special.block.js#93

function updateWatchOption() {
	var blocktarget = blockTargetWidget.getValue().trim(),

We should cast the value to a string before calling trim.

Acceptance criteria

This error is no longer encountered on loading Special:Block

Event Timeline

Change 902686 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/core@master] mediawiki.special.block.js: Cast target value to string

https://gerrit.wikimedia.org/r/902686

Change 902686 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.special.block.js: Cast target value to string

https://gerrit.wikimedia.org/r/902686

Bypassing QA, since they have a lot on their plate and this was fixing an error