From 87f456b0274c1c5d7b05f4236efc18a4812ea3d7 Mon Sep 17 00:00:00 2001 From: ckie Date: Wed, 29 Jun 2022 05:02:48 +0300 Subject: [PATCH 1/4] MessageComposerButtons: make button functions consistent Signed-off-by: ckie --- .../views/rooms/MessageComposerButtons.tsx | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/components/views/rooms/MessageComposerButtons.tsx b/src/components/views/rooms/MessageComposerButtons.tsx index 0a7f611b71c..8411f442d59 100644 --- a/src/components/views/rooms/MessageComposerButtons.tsx +++ b/src/components/views/rooms/MessageComposerButtons.tsx @@ -74,10 +74,10 @@ const MessageComposerButtons: React.FC = (props: IProps) => { ]; moreButtons = [ uploadButton(), // props passed via UploadButtonContext - showStickersButton(props), + stickersButton(props), voiceRecordingButton(props, narrow), props.showPollsButton && pollButton(room, props.relation), - showLocationButton(props, room, roomId, matrixClient), + props.showLocationButton && locationButton(props, room, roomId, matrixClient), ]; } else { mainButtons = [ @@ -85,10 +85,10 @@ const MessageComposerButtons: React.FC = (props: IProps) => { uploadButton(), // props passed via UploadButtonContext ]; moreButtons = [ - showStickersButton(props), + stickersButton(props), voiceRecordingButton(props, narrow), props.showPollsButton && pollButton(room, props.relation), - showLocationButton(props, room, roomId, matrixClient), + locationButton(props, room, roomId, matrixClient), ]; } @@ -265,7 +265,7 @@ const UploadButton = () => { />; }; -function showStickersButton(props: IProps): ReactElement { +function stickersButton(props: IProps): ReactElement { return ( props.showStickersButton ? { } } -function showLocationButton( +function locationButton( props: IProps, room: Room, roomId: string, matrixClient: MatrixClient, ): ReactElement { return ( - props.showLocationButton - ? - : null + ); } From c2b5597c1128b1f86c344fe380cfbcc4fdfd4db3 Mon Sep 17 00:00:00 2001 From: ckie Date: Wed, 29 Jun 2022 05:23:10 +0300 Subject: [PATCH 2/4] MessageComposerButtons: don't hide moreButtons behind dropdown in wide mode Signed-off-by: ckie --- .../views/rooms/MessageComposerButtons.tsx | 14 +++++--- .../rooms/MessageComposerButtons-test.tsx | 32 +++---------------- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/components/views/rooms/MessageComposerButtons.tsx b/src/components/views/rooms/MessageComposerButtons.tsx index 8411f442d59..2d1dc790587 100644 --- a/src/components/views/rooms/MessageComposerButtons.tsx +++ b/src/components/views/rooms/MessageComposerButtons.tsx @@ -103,11 +103,15 @@ const MessageComposerButtons: React.FC = (props: IProps) => { return { mainButtons } - { moreButtons.length > 0 && } + { moreButtons.length > 0 && + (narrow ? + : moreButtons + ) + } { props.isMenuOpen && ( = { }; describe("MessageComposerButtons", () => { - it("Renders emoji and upload buttons in wide mode", () => { + it("Renders all buttons in wide mode", () => { const buttons = wrapAndRender( { expect(buttonLabels(buttons)).toEqual([ "Emoji", "Attachment", - "More options", - ]); - }); - - it("Renders other buttons in menu in wide mode", () => { - const buttons = wrapAndRender( - , - false, - ); - - expect(buttonLabels(buttons)).toEqual([ - "Emoji", - "Attachment", - "More options", - [ - "Sticker", - "Voice Message", - "Poll", - "Location", - ], + "Sticker", + "Voice Message", + "Poll", + "Location", ]); }); From 09fd927491883ff52abb10e74a214a859fce184f Mon Sep 17 00:00:00 2001 From: ckie Date: Wed, 29 Jun 2022 05:42:07 +0300 Subject: [PATCH 3/4] Revert "MessageComposerButtons: don't hide moreButtons behind dropdown in wide mode" This reverts commit 5fd0906be1628e9d366e00bc19458f389dfeb1a3. --- .../views/rooms/MessageComposerButtons.tsx | 14 +++----- .../rooms/MessageComposerButtons-test.tsx | 32 ++++++++++++++++--- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/components/views/rooms/MessageComposerButtons.tsx b/src/components/views/rooms/MessageComposerButtons.tsx index 2d1dc790587..8411f442d59 100644 --- a/src/components/views/rooms/MessageComposerButtons.tsx +++ b/src/components/views/rooms/MessageComposerButtons.tsx @@ -103,15 +103,11 @@ const MessageComposerButtons: React.FC = (props: IProps) => { return { mainButtons } - { moreButtons.length > 0 && - (narrow ? - : moreButtons - ) - } + { moreButtons.length > 0 && } { props.isMenuOpen && ( = { }; describe("MessageComposerButtons", () => { - it("Renders all buttons in wide mode", () => { + it("Renders emoji and upload buttons in wide mode", () => { const buttons = wrapAndRender( { expect(buttonLabels(buttons)).toEqual([ "Emoji", "Attachment", - "Sticker", - "Voice Message", - "Poll", - "Location", + "More options", + ]); + }); + + it("Renders other buttons in menu in wide mode", () => { + const buttons = wrapAndRender( + , + false, + ); + + expect(buttonLabels(buttons)).toEqual([ + "Emoji", + "Attachment", + "More options", + [ + "Sticker", + "Voice Message", + "Poll", + "Location", + ], ]); }); From a0b49b6bea555bb228485fe323fb8af188e7a479 Mon Sep 17 00:00:00 2001 From: ckie Date: Wed, 29 Jun 2022 05:46:03 +0300 Subject: [PATCH 4/4] MessageComposerButtons: move some buttons out of the dropdown --- src/components/views/rooms/MessageComposerButtons.tsx | 4 ++-- test/components/views/rooms/MessageComposerButtons-test.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/views/rooms/MessageComposerButtons.tsx b/src/components/views/rooms/MessageComposerButtons.tsx index 8411f442d59..2d14700d302 100644 --- a/src/components/views/rooms/MessageComposerButtons.tsx +++ b/src/components/views/rooms/MessageComposerButtons.tsx @@ -82,11 +82,11 @@ const MessageComposerButtons: React.FC = (props: IProps) => { } else { mainButtons = [ emojiButton(props), + stickersButton(props), + voiceRecordingButton(props, narrow), uploadButton(), // props passed via UploadButtonContext ]; moreButtons = [ - stickersButton(props), - voiceRecordingButton(props, narrow), props.showPollsButton && pollButton(room, props.relation), locationButton(props, room, roomId, matrixClient), ]; diff --git a/test/components/views/rooms/MessageComposerButtons-test.tsx b/test/components/views/rooms/MessageComposerButtons-test.tsx index f0e736c032c..2c31b763604 100644 --- a/test/components/views/rooms/MessageComposerButtons-test.tsx +++ b/test/components/views/rooms/MessageComposerButtons-test.tsx @@ -54,6 +54,8 @@ describe("MessageComposerButtons", () => { expect(buttonLabels(buttons)).toEqual([ "Emoji", + "Sticker", + "Voice Message", "Attachment", "More options", ]); @@ -73,11 +75,11 @@ describe("MessageComposerButtons", () => { expect(buttonLabels(buttons)).toEqual([ "Emoji", + "Sticker", + "Voice Message", "Attachment", "More options", [ - "Sticker", - "Voice Message", "Poll", "Location", ],