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

Commit

Permalink
Make keyboard handling in and out of autocomplete completions consist…
Browse files Browse the repository at this point in the history
…ent (#11344)

* Make keyboard handling in and out of autocomplete completions consistent

* Add test
  • Loading branch information
t3chguy authored Aug 1, 2023
1 parent b2eac5b commit 340e301
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit 340e301

Please sign in to comment.