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

Commit c235472

Browse files
Search for users on paste
Signed-off-by: Peter Scheu <peter.scheu@aceart.de>
1 parent 5636a9f commit c235472

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

cypress/e2e/invite/invite-dialog.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,16 @@ describe("Invite dialog", function () {
181181
// Assert that the message is displayed at the bottom
182182
cy.get(".mx_EventTile_last").findByText("Hello").should("exist");
183183
});
184+
185+
it("should support pasting one username that is not a mx id or email", () => {
186+
cy.get(".mx_RoomList").within(() => {
187+
cy.findByRole("button", { name: "Start chat" }).click();
188+
});
189+
cy.get(".mx_InviteDialog_other").within(() => {
190+
cy.findByTestId("invite-dialog-input").invoke("val", "test");
191+
cy.findByText("Failed to find the following users").should("not.exist");
192+
cy.findByTestId("invite-dialog-input").invoke("val", "test,test,test");
193+
cy.findByText("Failed to find the following users").should("exist");
194+
});
195+
});
184196
});

src/components/views/dialogs/InviteDialog.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -870,11 +870,17 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
870870
return;
871871
}
872872

873+
const text = e.clipboardData.getData("text");
874+
const potentialAddresses = this.parseFilter(text);
875+
// one search term which is not a mxid or email address
876+
if (potentialAddresses.length === 1 && !potentialAddresses[0].includes("@")) {
877+
return;
878+
}
879+
873880
// Prevent the text being pasted into the input
874881
e.preventDefault();
875882

876883
// Process it as a list of addresses to add instead
877-
const text = e.clipboardData.getData("text");
878884
const possibleMembers = [
879885
// If we can avoid hitting the profile endpoint, we should.
880886
...this.state.recents,
@@ -889,8 +895,6 @@ export default class InviteDialog extends React.PureComponent<Props, IInviteDial
889895
// Will be displayed as filter text to provide feedback.
890896
const unableToAddMore: string[] = [];
891897

892-
const potentialAddresses = this.parseFilter(text);
893-
894898
for (const address of potentialAddresses) {
895899
const member = possibleMembers.find((m) => m.userId === address);
896900
if (member) {

0 commit comments

Comments
 (0)