Make keyboard handling in and out of autocomplete completions consistent (#11344)
* Make keyboard handling in and out of autocomplete completions consistent * Add test
This commit is contained in:
parent
b2eac5b65c
commit
340e301844
2 changed files with 12 additions and 2 deletions
|
@ -554,8 +554,6 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
|
||||||
autoComplete.onEscape(event);
|
autoComplete.onEscape(event);
|
||||||
handled = true;
|
handled = true;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
return; // don't preventDefault on anything else
|
|
||||||
}
|
}
|
||||||
} else if (autocompleteAction === KeyBindingAction.ForceCompleteAutocomplete && !this.state.showVisualBell) {
|
} else if (autocompleteAction === KeyBindingAction.ForceCompleteAutocomplete && !this.state.showVisualBell) {
|
||||||
// there is no current autocomplete window, try to open it
|
// there is no current autocomplete window, try to open it
|
||||||
|
|
|
@ -82,6 +82,18 @@ describe("BasicMessageComposer", () => {
|
||||||
expect(transformedText).toBe(after + " ");
|
expect(transformedText).toBe(after + " ");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not mangle shift-enter when the autocomplete is open", async () => {
|
||||||
|
const model = new EditorModel([], pc, renderer);
|
||||||
|
render(<BasicMessageComposer model={model} room={room} />);
|
||||||
|
|
||||||
|
const input = screen.getByRole("textbox");
|
||||||
|
|
||||||
|
await userEvent.type(input, "/plain foobar");
|
||||||
|
await userEvent.type(input, "{Shift>}{Enter}{/Shift}");
|
||||||
|
const transformedText = model.parts.map((part) => part.text).join("");
|
||||||
|
expect(transformedText).toBe("/plain foobar\n");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function generateMockDataTransferForString(string: string): DataTransfer {
|
function generateMockDataTransferForString(string: string): DataTransfer {
|
||||||
|
|
Loading…
Reference in a new issue