Page MenuHomePhabricator

Link dialog makes API requests with placeholder as title
Closed, ResolvedPublic

Description

Steps to reproduce:

Current result: The following API request is generated: https://www.mediawiki.org/w/api.php?action=query&format=json&formatversion=2&prop=pageprops&titles=Page+title+or+URL&ppprop=disambiguation
The placeholder Page title or URL should never be treated as title.

Event Timeline

A possible solution is to use the module 'jquery.placeholder' instead of the own placeholder implementation.

https://github.com/mathiasbynens/jquery-placeholder/ supports val():

You’ll still be able to use jQuery#val() to get and set the input values. If the element is currently showing a placeholder, .val() will return an empty string instead of the placeholder text, just like it does in browsers with a native @placeholder implementation

@Fomafix This aspect of jquery.placeholder was more a mandatory bug fix than a feature. Placeholders are a native feature of the web (they are only used visually as fallback when the field is empty). "value" or val() was never affected and jquery.placeholder naturally tries to emulate this as closely as possible.

jquery.placeholder has been removed in edd4985b7240 as all our Grade A browsers now support this natively. I'm not sure why this input field was not using a the placeholder feature for what is clearly placeholder text (with or without jquery.placeholder). But looks like something we should fix indeed.

Placeholders work as follows:

<input type="text" placeholder="This is displayed when there is no value">

Currently, the WikiEditor dialogs feature uses a tooltip data attribute and lots of comparison logic like val=='' to apply this as the real value when it is empty etc. All of that should be removed.

Change 473668 had a related patch set uploaded (by TheDJ; owner: TheDJ):
[mediawiki/extensions/WikiEditor@master] LinkDialog: use placdeholder instead of fake values

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

Change 473668 merged by jenkins-bot:
[mediawiki/extensions/WikiEditor@master] LinkDialog: use placeholder instead of fake values

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