Page MenuHomePhabricator

mw.widgets.TitleInputWidget doesn't show query when it's a substring of an existing title
Closed, ResolvedPublic2 Estimated Story Points

Description

In adding a TitleInputWidget to the link-insert dialog (for T289214), I'm running into an issue where the typed title isn't available for selection if it doesn't exist but is a prefix substring of an existing title.

For example, in a wiki with one page Test page, it's not possible to select Test as a title, but it is possible to select Testing.

Non-existing title, shows red link:Non-existing title doesn't show (it should be showing two items here, Test and Test page):
test.png (129Γ—489 px, 9 KB)
test-page.png (124Γ—489 px, 7 KB)

The addQueryInput config parameter is supposed to "Add exact user's input query to results", but this only adds the exact input when the page title exists, and then it ends up being redundant and lists the page twice (if there's a normalization difference):

two-test-pages.png (183Γ—492 px, 10 KB)

(Although, perhaps showing it twice is okay, because users might want to select the non-normalized form.)

What I think should be happening:

  • Typing test should show two results: Test and Test page (this is what this task is about)
  • Typing testing should show Testing
  • Typing test page should show Test page

Event Timeline

Change 726573 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/core@master] Improve TitleWidget search results

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

I've been meaning to report this. I run into this most often when linking to user pages since many of us use global user pages now, and that means the page technically doesn't exist locally, for the purposes of prefix index:

Screenshot 2021-10-15 at 03.21.02.png (754Γ—1 px, 82 KB)

One thing to keep in mind, though, is both remote file pages and remote user pages, are considered existant, so in implementing it may be worth making sure that these are not assumed to be red links by the JavaScript code, but rather handled server-side and passed through the isKnown() check as other linking and searching features do.

I believe for the user/file page issue in particular, a task exists for the search field / prefixindex api more generally, which I recall seeing resolved a number of years ago already. So perhaps this has regressed? Or perhaps the widget is using a different API, or using it such that this doesn't come along for free already?

That's a good point. It currently does show global user pages and InstantCommons filenames as not existing β€” that's the same as the normal search box though (as you say), so probably any fix for that should be broader than just this.

This widget is using the prefixsearch API, and no it doesn't look like that's been changed to return these quasi-existing pages. I've tried finding a task for that, but haven't; do you remember which it is?

Anyway, even if these pages are shown in titlewidgets as not existing, they'll at least be selectable (in the normalized form, too), which is an improvement on the status quo I think.

Daimona subscribed.

I agree that this is already an improvement, compared to the status quo. I think maybe the prefixsearch API could have an option to always include the queried title, which would do essentially what we're doing client-side, but more efficiently and accounting for edge cases like global user pages.

Change 726573 merged by jenkins-bot:

[mediawiki/core@master] Improve TitleWidget search results

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

@Samwilson I am not sure if I have understood this change correctly. On beta, I am still only seeing red links if there are no other results returned.

For example, typing "polar" returns no exact match but does not show a red link:

add_link.png (319Γ—420 px, 14 KB)

@Samwilson I am not sure if I have understood this change correctly. On beta, I am still only seeing red links if there are no other results returned.

For example, typing "polar" returns no exact match but does not show a red link:

add_link.png (319Γ—420 px, 14 KB)

Oh, wait, that is VisualEditor. I see this change is only for Source Editor. Nevermind.

On source editor, I see this instead:

add_link_sourceeditor.png (347Γ—520 px, 15 KB)

Yep, this is only for WikiEditor (or, rather, anywhere that the addQueryInput option is used for a TitleInputWidget).

In the Source Editor, while using the Insert link functionality to search for pages on the wiki, if the title you have entered is not exactly matched it will appear in the search results as a red link.

source_editor_insert_link_steps_1.png (450Γ—2 px, 103 KB)

Before:

Non-existing title, shows red link:Non-existing title doesn't show (it should be showing two items here, Test and Test page):The addQueryInput config parameter is supposed to "Add exact user's input query to results", but this only adds the exact input when the page title exists, and then it ends up being redundant and lists the page twice (if there's a normalization difference)
test.png (129Γ—489 px, 9 KB)
test-page.png (124Γ—489 px, 7 KB)
two-test-pages.png (183Γ—492 px, 10 KB)

After:

testing.png (113Γ—485 px, 8 KB)
test.png (167Γ—475 px, 8 KB)
test_page.png (168Γ—476 px, 7 KB)

Which is consistent with "What I think should be happening" in the description (apart from perhaps the third point, but we haven't changed that behaviour).

Before:

Screenshot 2021-10-15 at 03.21.02.png (754Γ—1 px, 82 KB)

After:

user_krinkle.png (608Γ—480 px, 42 KB)

It shows the global user page as being non-existent. However, there seems to be agreement in this ticket that fixing this is outside the scope of this ticket.

I have tested that this behaves the same when:

  • searching for pages which are disambiguation pages or redirects to other pages
  • searching for pages in different namespaces ("Template", "User")
  • searching for pages with "special" characters (e.g. pages like these)
  • searching on an RTL wiki

Test environment: https://en.wikipedia.beta.wmflabs.org and https://he.wikipedia.beta.wmflabs.org MediaWiki 1.38.0-alpha (164ec5c) 12:55, 26 October 2021.
Test browser: Firefox 78