Page MenuHomePhabricator

[Request] ScopedTypeaheadSearch: the component replaces server-side-rendered Vector search in a way that makes sense
Closed, ResolvedPublic2 Estimated Story Points

Description

Problem

The ScopedTypeaheadSearch Vue component replaces Vector's search on page load. This causes several issues:

  • because the server-side rendering of search is not identical to ScopedTypeaheadSearch, the elements jump around on load
  • having the Vue component mount on page load is bad, performance-wise, since it happens regardless of whether the user is actually interacting with it
  • there's soon to be some major changes to the way Vector's search which would likely break ScopedTypeaheadSearch

Ideas being discussed

  • Mount the ScopedTypeaheadSearch component on focus rather than page load. This requires input from UX, as it means that the select component would not be visible until a user tries to search for something
  • Change server-side rendering to conditionally include a visually identical version of ScopedTypeaheadSearch. This has generally been rejected, as it adds complexity and maintenance burden.

Request to web team

Provide guidance on the following options:

  • Talk to Sarai about alternative designs that do not require change in server side rendering
  • Advise on preferred way to replace the TypeaheadSearch component that doesn't load Vue on page load
  • If server side rendering changes is required, recommend the preferred way to do this

Additional context

Requirement

The ScopedTypeaheadSearch Vue component must integrate with the Vector desktop skin without causing any functional or visual regressions to the search interface. Users must be able to interact with the search input and receive relevant, clickable type-ahead suggestions across all pages, with no unexpected layout changes or broken behavior during or after page load.

BDD

Feature: Search interface behaves correctly with ScopedTypeaheadSearch integration

  Scenario: Search interaction is functional on all pages
    Given I am using Vector on desktop
    When I interact with the search input on various pages
    Then I can type queries and receive type-ahead search suggestions
    And no visual layout issues occur during interaction

  Scenario: Search suggestions are relevant and clickable
    Given I have typed a valid search term
    When type-ahead suggestions appear
    Then I can click on a suggestion
    And I am taken to the correct search result page

  Scenario: Search interface passes exploratory interaction checks
    Given I am using Vector on desktop
    When I interact with the search input
    Then  keyboard navigation, RTL layout, and console output meet acceptance criteria

Test Steps

Test Case 1: Verify basic search functionality and layout

  1. Log in or use an anonymous session at https://en.wikipedia.beta.wmflabs.org using the Vector 2022 skin.
  2. Visit the Main Page.
  3. Focus the search bar without typing anything.
  4. Type a common query, e.g., Dog.
  5. AC1: Confirm type-ahead suggestions appear smoothly without layout jumps.
  6. Click on a search suggestion.
  7. AC2: Confirm you are navigated correctly to the selected article.
  8. Reload the page and observe:
  9. AC3: Confirm no layout shifting or repositioning occurs after page load.

Test Case 2: Conduct exploratory interaction checks

While performing search interactions, validate the following:

AC#CheckDetailsScreenshot
AC4Keyboard navigationArrow keys and Enter work for moving through and selecting suggestions.
AC5Escape key behaviorPressing Esc closes suggestions without clearing typed input.
AC6RTL language supportRTL languages (e.g., ?uselang=ar) show correctly aligned input and suggestion list.
AC7Console cleanlinessNo JS errors, Vue warnings, or console warnings appear during interaction.

QA Results - Beta

QA Results - Prod

Event Timeline

Jdlrobson-WMF renamed this task from ScopedTypeaheadSearch: the component replaces server-side-rendered Vector search in a way that makes sense to [Request] ScopedTypeaheadSearch: the component replaces server-side-rendered Vector search in a way that makes sense.Apr 1 2025, 5:25 PM
Jdlrobson-WMF added a project: Web-Team.
Jdlrobson-WMF updated the task description. (Show Details)
Jdlrobson-WMF moved this task from Incoming to Q4 on the Web-Team board.
Jdlrobson changed the task status from Open to In Progress.Apr 2 2025, 8:08 PM
NOTE: <DISCLAIMER> I just wanted to provide an update, but I wanted to add a disclaimer that this is currently my recommendation and not a team recommendation. I am still in the process of discussing this with the team but due to some vacation/sickness/a team event we haven't had time to do that. I am sharing this in case in the hope it is helpful to see what. solution here might look like.

When we originally built the TypeaheadSearch component we designed it so that the API could be easily swapped out, but we didn't consider for the possibility of the search being swapped out.

I noticed that the proposed TypeaheadSearch works around this by unconditionally loading on page load and as a side effect of that remove the elements that have focus events for loading the default component. This will be fragile, and highly likely to break in future as the search component evolves (particularly if we begin to load Vue on page load). For this reason, I would strongly recommend that we provide a supported API for swapping out the component for Wikidata. My proposal would be to update the existing SkinPageReadyConfigHook hook to allow you to swap out the default in a better supported way. I did a MVP to show how that might work and this would require one minor change in core: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/1133957?usp=search

For server side rendering I think this is more troublesome and personally I would avoid changing the server side if we can. As a last resort, if this is a hard requirement, one compromise we might consider is making use of HTML comments that identify the start and end of the TypeaheadSearch component: https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/1133268 - however I wouldn't feel comfortable endorsing that or guaranteeing support so it would require WMDE actively tests the integration point. I believe @Sarai-WMF has already reached out with some ideas about how to avoid this.

I hope this is as helpful starting point!

Jdlrobson-WMF changed the task status from In Progress to Open.Apr 23 2025, 7:14 AM
Jdlrobson-WMF set the point value for this task to 2.

Hoping to discuss this with team shortly.

Change #1133957 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] Allow extensions / skins to swap out the search module

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

wanted to give an update from our side:

After discussing with @Sarai-WMF and @LarissaHonsek, we have a plan to mount the Vue component on user interaction, using an animation to transition from the server-rendered version as it currently is.

That change in core looks good to me, with the caveat that I'm still new to the hook system.

@Jdlrobson I added a draft of how loading our scoped typeahead search on input focus might look: https://gerrit.wikimedia.org/r/1139440 . I wasn't able directly to make it work with your draft patch and I added a comment on the POC - might just be something I'm doing wrong there, but I couldn't work out how to stop vector installing its focus handler using the hook config you provided.

Change #1139875 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Vector@master] WIP: Vector uses core searchLoader

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

Hey please see if https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/1139875/1 alleviates the problem. I'm out the rest of this week, but come next week we should be able to switch focus to this task!

Change #1142685 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/extensions/ExternalGuidance@master] Drop use of deprecated mw.Uri library

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

Change #1133957 merged by jenkins-bot:

[mediawiki/core@master] Allow extensions / skins to swap out the search module

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

Change #1139875 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Vector uses core searchLoader

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

Jdlrobson-WMF added a subscriber: LMora-WMF.

Edward could you do some exploratory QA on the desktop search interface in https://en.wikipedia.beta.wmflabs.org/ and check on various pages that search is working as expected?

Change #1144587 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/skins/Vector@master] Add mw-searchInput class to sticky header search input

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

Edtadros subscribed.

Test Steps

Status: ❌ FAIL
Environment: Beta
OS: macOS
Browser: Chrome Canary
Device: MS

Test Case 1: Verify basic search functionality and layout

  1. Log in or use an anonymous session at https://en.wikipedia.beta.wmflabs.org using the Vector 2022 skin.
  2. Visit the Main Page.
  3. Focus the search bar without typing anything.
  4. Type a common query, e.g., Dog.
  5. ❌ AC1: Confirm type-ahead suggestions appear smoothly without layout jumps.

When you first type a character in the search field the field expands to the left

  1. Click on a search suggestion.
  2. ✅ AC2: Confirm you are navigated correctly to the selected article.
  3. Reload the page and observe:
  4. ✅ AC3: Confirm no layout shifting or repositioning occurs after page load.

screenshot 76.mov.gif (932×1 px, 1 MB)

screenshot 75.mov.gif (932×1 px, 1 MB)

Test Case 2: Conduct exploratory interaction checks

While performing search interactions, validate the following:

AC#CheckDetailsScreenshot
✅ AC4Keyboard navigationArrow keys and Enter work for moving through and selecting suggestions.
screenshot 78.mov.gif (932×1 px, 1 MB)
✅ AC5Escape key behaviorPressing Esc closes suggestions without clearing typed input.
screenshot 79.mov.gif (932×1 px, 620 KB)
✅ AC6RTL language supportRTL languages (e.g., ?uselang=ar) show correctly aligned input and suggestion list.
screenshot 80.mov.gif (932×1 px, 764 KB)
screenshot 81.mov.gif (932×950 px, 878 KB)
✅ AC7Console cleanlinessNo JS errors, Vue warnings, or console warnings appear during interaction.No console errors were observed
Edtadros updated the task description. (Show Details)
Edtadros updated the task description. (Show Details)

Change #1144587 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Add mw-searchInput class to sticky header search input

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

❌ AC1: Confirm type-ahead suggestions appear smoothly without layout jumps.

The layout jump is intentional here (you can also see it in production right now) - the expansion accommodates the image thumbnails so that the search icon is aligned with them:

image.png (303×360 px, 35 KB)

Moving to sign off with that in mind.

Jdlrobson-WMF lowered the priority of this task from High to Medium.

Test Steps

Status: ✅ Prod
Environment: enwiki
OS: macOS
Browser: Chrome Canary
Device: MS

Test Case 1: Verify basic search functionality and layout

  1. Log in or use an anonymous session at https://en.wikipedia.org using the Vector 2022 skin.
  2. Visit the Main Page.
  3. Focus the search bar without typing anything.
  4. Type a common query, e.g., Dog.
  5. ✅ AC1: Confirm type-ahead suggestions appear smoothly without layout jumps.

screenshot 89.mov.gif (944×1 px, 1 MB)

  1. Click on a search suggestion.
  2. ✅ AC2: Confirm you are navigated correctly to the selected article.

See AC3

  1. Reload the page and observe:
  2. ✅ AC3: Confirm no layout shifting or repositioning occurs after page load.

screenshot 90.mov.gif (944×1 px, 1 MB)

Test Case 2: Conduct exploratory interaction checks

While performing search interactions, validate the following:

AC#CheckDetailsScreenshot
✅ AC4Keyboard navigationArrow keys and Enter work for moving through and selecting suggestions.
screenshot 91.mov.gif (944×1 px, 1 MB)
✅ AC5Escape key behaviorPressing Esc closes suggestions without clearing typed input.
screenshot 92.mov.gif (944×1 px, 958 KB)
✅ AC6RTL language supportRTL languages (e.g., ?uselang=ar) show correctly aligned input and suggestion list.
screenshot 93.mov.gif (944×1 px, 1 MB)
✅ AC7Console cleanlinessNo JS errors, Vue warnings, or console warnings appear during interaction.No console errors were observed