Page MenuHomePhabricator

TextInput and Lookup fields: Find a way to make the fields' width wrap their content and expand when focus
Closed, ResolvedPublic

Description

Description

The design specifications of the Default View show text and select fields having the minimum necessary width to fit the content, and when focused, they would expand to take 100% horizontal space. There are some difficulties on controlling the width of the TextInput and Lookup fields so that they fit the content, but it can be worked out.

This task is to find an appropriate solution that can fulfill these designs.

Desired behavior/Acceptance criteria

For text and select fields:

  • The width should be the minimum necessary to wrap the content (if any)
    • If no content, the width should wrap the placeholder
    • If no content or placeholder, define a default width
  • On focus, the width should be expanded into the 100%
  • The expansion should be animated

Devices and Design (URLs or screenshots)

https://www.figma.com/file/uNBSv1e4ceA8tGNr29R9vp/Default-component


Completion checklist

Event Timeline

Change 880420 had a related patch set uploaded (by Genoveva Galarza; author: Genoveva Galarza):

[mediawiki/extensions/WikiLambda@master] [WIP] Add width fit-content features to ZObjectSelector and TextInput fields

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

While reviewing, I noticed two things:

  1. The dropdown icon in the selector is no longer all the way to the right of the input box, but closer to the middle. [ Key 0 in the example screenshot ]. It feels like it should still be all the way to the right even when not expanded.
  1. When the text is quite long, it gets cut off when not expanded. Should we consider adding a "..." or something to indicate there is more text that will be visible when it is expanded? It's also worth noting that, even when expanded, the entire text is not always visible. [ Key 1 in the example screenshot ]

Screenshot 2023-01-17 at 3.28.56 PM.png (312×856 px, 27 KB)

Re 2: I was hoping the text box would open to the next line and make enough space for longer text

Re 1: Ah thanks!! That doesn't happen in my Chrome, but will test in other browsers and see if I can find the reason! (edit: managed to replicate this behavior, thanks! will fix and update)

Re 2: This patch addresses only ZString, ZReference and ZObjectType, I'm not doing any changes on ZMonolingualString as it's being worked on another patch.

Done.

  1. This should work now for fields ZString ZReference and ZObjectType. The field should fit the content and expand the way it shows in the following video. I've tried in all my browsers, but let me know if the behavior looks the same:

https://www.loom.com/share/afa581b53ad84f0580d005e137cc4955

  1. ZMonolingualString will remain as is until the working patch is landed (to avoid messy rebases)

Change 880420 merged by jenkins-bot:

[mediawiki/extensions/WikiLambda@master] Add width fit-content features to ZObjectSelector and TextInput fields

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

Tested, and worked in all tests! Yay!