Bug: Edit recipient pill: Making short email address longer does not adjust pill size, pushes address out of pill, cursor outside pill
Status: RESOLVED
Priority: P1
Resolution: FIXED
Created: 2020-04-04 15:36:27+00:00
Resolved: 2020-06-11 10:44:56+00:00

Editing an existing pill leads to all sorts of weird behaviour as the pill size does not auto-adjust to longer email addresses. It definitely should.

STR

1) compose to:
`JohnWD@foo.bar` [sic, length matters], press Enter to create pill
`nextpill <bar@baz.com>`, Enter
2) edit 1st pill (short address, so pill border expands by about 7 characters to predefined default length)
3) add display name and opening bracket before plain email address ( `|` represents cursor):
`John Darlington <|`JohnWD@foo.bar
4) while still editing, press END key now and add closing bracket

Actual Result
- for short addresses, pill frame initially expands to predefined default length; for addresses longer than default length, it does *not* expand: somewhat inconsistent.
- Default pill length is way too short, can't even fit a shorter common address like `John Johnson <john.johnson@gmail.com>`
- As soon as the entire address exceeds pill default length, it is pushed outside the pill frame to the right side (and sometimes to the left), and even overlaps the next pill: odd (see screenshot 1).
- Worse, when you move cursor to the END of pill text (e.g. to change domain name), you'll end up typing *outside* the pill frame: more than odd! So that part is like an extreme variant of bug 1609958.

Expected Result
- If we need a default length for pills at all, it must be longer to fit at regular addresses like `John Johnson <john.johnson@gmail.com>`
- Need some way of ensuring that during pill editing, the full email address is always inside the pill frame, i.e. the pill must dynamically adjust in size somehow

Possible behaviours
1) **initial expansion**: expand pill size when entering edit mode (always, not only for short addresses), and probably expand more (say 15em)
2) **initial close fit**: alternatively, do *not* expand pill size when entering edit mode; start editing in "close fit pill", then instead, only do 3)
3) **gradual excess expansion**: when user input gets longer than pill frame, dynamically expand pill size character by character as user types along, which will slow push other pills along (just like it would for any subsequent text in any input, nothing strange here)
4) **stepwise excess expansion**: Alternatively, whenever user input get's longer than pill frame (triggered early with some blank-space offset), expand pill size by a fixed measure (say 15em).

I'm not sure which behaviour would feel most convenient and natural, but the current behaviour is odd and wrong.
I do like that we initially expand the pill, so I think 1) is good for starters.
After that, when input reaches the pill limit again (with some early-trigger offset of at least 5em permanent blank space on the right), our choice is between 3) gradual excess expansion and 4) stepwise excess expansion. 3) feels natural, but it keeps pushing pills around as you type. Maybe 4) stepwise expansion is good. Let's not be too stingy, adding 15 em blank space is minimum imo.