mirror of
https://github.com/bulwarkmail/webmail.git
synced 2026-11-04 16:14:07 +00:00
fix: keep a recipient's closing bracket when Backspace pulls it back to edit
This commit is contained in:
@@ -538,6 +538,14 @@ describe('composer with the @ recipient list', () => {
|
||||
expect(onClose).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('pulls the last recipient back whole on Backspace, without the key deleting its last character', async () => {
|
||||
await renderComposer({ to: 'Sarah Kim <sarah@example.com>' });
|
||||
const to = within(screen.getByTestId('composer-to')).getByRole('combobox') as HTMLInputElement;
|
||||
// fireEvent returns false when the handler stopped the key's default action.
|
||||
expect(fireEvent.keyDown(to, { key: 'Backspace' })).toBe(false);
|
||||
expect(to.value).toBe('Sarah Kim <sarah@example.com>');
|
||||
});
|
||||
|
||||
// The directory picker is drawn inside the composer itself, not portaled.
|
||||
it('lets Escape in the directory picker leave the composer alone', async () => {
|
||||
// Every other capability answers nothing.
|
||||
|
||||
@@ -5930,6 +5930,8 @@ export function RecipientChipInput({
|
||||
// Backspace on an empty input pulls the last chip back into the input for
|
||||
// quick editing.
|
||||
if (e.key === 'Backspace' && !inputText && chips.length > 0) {
|
||||
// Or the key goes on to delete the closing ">" of what was just put back.
|
||||
e.preventDefault();
|
||||
const lastChip = chips[chips.length - 1];
|
||||
onChipsChange(chips.slice(0, -1));
|
||||
onInputChange(formatRecipient(lastChip.name, lastChip.email));
|
||||
|
||||
Reference in New Issue
Block a user