Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Make keyboard handling in and out of autocomplete completions consistent #11344

Merged
merged 2 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/components/views/rooms/BasicMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/components/views/rooms/BasicMessageComposer-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down