Page MenuHomePhabricator

Typed List component: Implement solution to limit number of list items presented to the user at once
Closed, ResolvedPublic

Description

Description

During Q3 we conducted a detailed analysis of the Front End performance issues, origin and mitigation strategies.

As part of the goal to reduce the number of components rendered in the page, the most effective measure is to limit typed list items presented at once.

Implement whatever design solution we've come up during T391129: Design: Limit number of items rendered in typed lists

Desired behavior/Acceptance criteria

1. Loading & Sorting

  • User loads typed list
  • List Item
    • Items are sorted by language priority:
      • User language
      • Fallback languages
      • Common languages (spanish, french?)

2. Show vs. Hide “Load More”

  • If items > limit → show Load More button
  • If items ≤ limit → show all items, no button
  • The limit only is used to limit the list on first load. any user interaction: adding an item from dialog, adding a blank item or deleting an item from the list, ignore the limit set, so the list can become shorter or longer after user interaction.

3. Dialog Behavior

  • Clicking Load More opens dialog
  • Dialog shows all items in store for the typed list, alphabetically sorted

4. Item Click in Dialog

  • If item already in typed list → close dialog
  • If item in store but not in typed list
    • should append to the items in the typed list
  • If item not in store and therefor not in typed list
    • if not in edit mode: link to edit page
    • if in edit mode:
      • need to add the item to the store for this typed list,
      • then; should append to the items in the typed list

5. Adding Blank Items

  • Clicking Add Button →
    • currently creates blank item in store (pushItemsByKeyPath),
    • then; should append to the items in the typed list

6. Show More Button Visibility

  • Disappears only when all store items from the dialog are added to the typed list

7. Editing the List

  • User can:
    • NOT Move items up or down in the typed list →
      • the modeselector move before and after will be disabled for these mono/multi-linguallists because for each user the order represented will be different.
    • Delete items →
      • currently updates store with deleteListItemsByKeyPath where it removed the item from the typed list in the store
      • should visually remove the item from the typed list.

Devices and Design (URLs or screenshots)

Figma: https://www.figma.com/design/EzzGFcdy5VM1vDKSyiF9Ci/Limit-number-of-items-rendered-in-typed-lists?node-id=177-16141&t=cb6jCGyhOEDQwin2-1
Video demo: https://drive.google.com/file/d/1Qfj2-oEFciH_wIjTH6CnV1CY1BWE8vSo/view

Screenshot 2025-06-20 at 5.19.24 PM.png (1×3 px, 663 KB)

User flows

User interactions: Deleting and Adding items

I will describe some interactions with the types list vs dialog

LIMIT = 4
INITIAL STORE ORDER (incoming data):

  1. german - keypath z12k1.1
  2. some fallback lang - keypath z12k1.2
  3. english - keypath z12k1.3
  4. userlang - keypath z12.k1.4
  5. arabic - keypath z12k1.5

A:
List:

  1. userlang - keypath z12.k1.4
  2. some fallback lang - keypath z12k1.2

dialog - alphabetic:

  1. arabic - keypath z12k1.5
  2. german - keypath z12k1.1

ACTION = adding arabic/z12k1.5

B:
List:

  1. userlang - keypath z12.k1.5
  2. some fallback lang - keypath z12k1.2
  3. arabic - keypath z12k1.13

Dialog:

  1. german - keypath z12k1.1

ACTION = remove userlang/z12.k1.4

D:
List:

  1. some fallback lang - keypath z12k1.2
  2. arabic - keypath z12k1.5

Dialog:

  1. german - keypath z12k1.1

ACTION = Add german/z12k1.1

E:
List:

  1. some fallback lang - keypath z12k1.2
  2. arabic - keypath z12k1.5
  3. german - keypath z12k1.1

Button to show dialog is hidden. no more items to show in dialog.

ACTION = remove some fallback lang/12k1.2

F:
List:

  1. arabic - keypath z12k1.5
  2. german - keypath z12k1.1

Button to show dialog is hidden. no more items to show in dialog.

ACTION = move arabic down in the list

G:
List:

  1. german - keypath z12k1.1
  2. arabic - keypath z12k1.5

Button to show dialog is hidden. no more items to show in dialog.

ACTION = add new blank item

H:
List:

  1. german - keypath z12k1.1
  2. arabic - keypath z12k1.5
  3. blank item - keypath z12k1.6

Button to show dialog is hidden. no more items to show in dialog.

ACTION = add 3 new blank items

I:
List:

  1. german - keypath z12k1.1
  2. arabic - keypath z12k1.5
  3. blank item - keypath z12k1.6
  4. blank item - keypath z12k1.7
  5. blank item - keypath z12k1.8
  6. blank item - keypath z12k1.9

Button to show dialog is hidden. no more items to show in dialog.

User interactions: Searching and adding an item

State A
List:

  1. userlang - keypath z12.k1.4
  2. some fallback lang - keypath z12k1.2

Dialog (alphabetic):

  1. arabic - keypath z12k1.5
  2. german - keypath z12k1.1

ACTION = search for 'spanish'

State B
List:

  1. userlang - keypath z12.k1.4
  2. some fallback lang - keypath z12k1.2

Dialog (alphabetic):

  1. spanish - keypath NONE | "Add language" button in blue

ACTION = add 'spanish'

State C
List:

  1. userlang - keypath z12.k1.4
  2. some fallback lang - keypath z12k1.2
  3. spanish - keypath z12k1.6 (store items length + 1)

Dialog (alphabetic):

  1. arabic - keypath z12k1.5
  2. german - keypath z12k1.1

Important considerations

  • Deleting items Index/keyPath shifts in the store
  • Language needs to be unique. We need a unique identifier because deleting causes index/keyPath shifts. So we need to be able to count on 1 language per Typed List.
  • We need to restrict the lookup in expanded mode for monolingual string items in a typed list to only be able to show languages that are not yet visible in the Typed List. Also we need to filter the suggested items. (Should we also prevent on backend?)
  • We need to decide what to do with double languages in already existing content. We probably need to first figure out if those cases actually exist.
  • We need to test with more fallback languages than 10
  • We need to test with an empty list

Completion checklist

Event Timeline

DSantamaria triaged this task as Medium priority.Apr 9 2025, 4:56 PM
DSmit-WMF changed the task status from Open to In Progress.Aug 22 2025, 11:30 AM

Open questions:

  1. Is this solution only for typed lists with type Z11 / monolingual text? ANSWER: Yes monolingual and multilingual
  2. How are the fallbacks determined ? what if there are no fallbacks ? (we just show 1?) ANSWER: mw fallbacks and 2 others
  3. I presume this is not when creating a new object/type/typed list right? Only when viewing or editing existing lists? ANSWER: Both
  4. What is the sorting based on in the design in the dialog in 'search dialog default' (see screenshot) when you did not search yet. Also how are these items determined. I see english twice in the example; selected on the page and in the dialog. Why do they not have an 'add language' button/text in blue? ANSWER: sort like about languages
  5. What does the search do? Search for language and the value? how is the sorting determined after search? ANSWER: use about languages. it searches through the languages using labels api
  6. Which component is 'add language'? codex only has a quiet button. Is this clickable? Normally the whole thing is clickable with a grey bg (see about languages dialog). ANSWER: use the <a> from about languages
  7. also I need to but the 'view more' on top of the [+]-button in edit. because of the way its structured. ANSWER: ok
  8. We can move an item up and down in the list using the mode selector. But how does that make any sense anymore now with this solution every user sees a different order ? If you save the order is lost anyway and depending on a users settings. ANSWER: remove the feature for this
  9. Grgeory: I was thinking we could have it in read mode also. So, if an editor is searching for a language and that language hasn't been added, they don't have to close the dialog, go to edit view, click on + and select the language. It will be faster from the read mode they can see the 'Add language' , and clicking on it takes them to the edit mode with the language selected. ANSWER DAPHNE: this seems highly complex and would skip that for now since its already pretty complex solution.

Change #1182133 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] Typed List: limit number of list items for Z11/MonolingualString

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

DSmit-WMF updated the task description. (Show Details)

Change #1182133 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Typed List: limit number of list items for Z12/MultilingualString

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

Change #1190984 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] ZMultilingualString: use ISO codes instead of ZIDs

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

Change #1191016 had a related patch set uploaded (by Daphne Smit; author: Daphne Smit):

[mediawiki/extensions/WikiLambda@master] ZMultilingualStringDialog: use server-side language mapping to get language labels

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

Change #1190984 abandoned by Daphne Smit:

[mediawiki/extensions/WikiLambda@master] ZMultilingualString: use ISO codes instead of ZIDs

Reason:

we dont need iso codes

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

Observed a related behavior issue:

  • when editing a language code of a monolingual string, the component collapses automatically after every keystroke
  • additionally, on the current WIP patch, whenever the final code matches an existing language, it is also removed from the selected list of languages

automatic-collapse-due-to-reasons.gif (761×875 px, 469 KB)

"Add language" call to action in non-main store namespaces should not be visible in suggested languages list as well:

Screenshot from 2025-09-29 14-03-37.png (969×1 px, 86 KB)

I think all issues have been adressed

Change #1191016 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] ZMultilingualStringDialog: use server-side language mapping to get language labels

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