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:
Michael Telatynski 2023-08-01 10:06:37 +01:00 committed by GitHub
parent b2eac5b65c
commit 340e301844
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -554,8 +554,6 @@ export default class BasicMessageEditor extends React.Component<IProps, IState>
autoComplete.onEscape(event);
handled = true;
break;
default:
return; // don't preventDefault on anything else
}
} else if (autocompleteAction === KeyBindingAction.ForceCompleteAutocomplete && !this.state.showVisualBell) {
// there is no current autocomplete window, try to open it

View file

@ -82,6 +82,18 @@ describe("BasicMessageComposer", () => {
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 {