diff --git a/src/components/views/rooms/MessageComposer.tsx b/src/components/views/rooms/MessageComposer.tsx index 3698f87d2e9..bf95f722e4d 100644 --- a/src/components/views/rooms/MessageComposer.tsx +++ b/src/components/views/rooms/MessageComposer.tsx @@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -import React, { createRef } from 'react'; +import React, { ComponentProps, createRef } from 'react'; import classNames from 'classnames'; import { MatrixEvent, IEventRelation } from "matrix-js-sdk/src/models/event"; import { Room } from "matrix-js-sdk/src/models/room"; @@ -80,10 +80,22 @@ function SendButton(props: ISendButtonProps) { ); } -interface IEmojiButtonProps { +interface ICollapsibleButtonProps extends ComponentProps { + narrowMode: boolean; + title: string; +} + +const CollapsibleButton = ({ narrowMode, title, ...props }: ICollapsibleButtonProps) => { + return ; +}; + +interface IEmojiButtonProps extends Pick { addEmoji: (unicode: string) => boolean; menuPosition: AboveLeftOf; - narrowMode: boolean; } const EmojiButton: React.FC = ({ addEmoji, menuPosition, narrowMode }) => { @@ -108,18 +120,18 @@ const EmojiButton: React.FC = ({ addEmoji, menuPosition, narr // TODO: replace ContextMenuTooltipButton with a unified representation of // the header buttons and the right panel buttons return - { contextMenu } ; }; -interface ILocationButtonProps { +interface ILocationButtonProps extends Pick { room: Room; shareLocation: (uri: string, ts: number, type: LocationShareType, description: string) => boolean; menuPosition: AboveLeftOf; @@ -148,11 +160,11 @@ const LocationButton: React.FC = ({ shareLocation, menuPos // TODO: replace ContextMenuTooltipButton with a unified representation of // the header buttons and the right panel buttons return - { contextMenu } @@ -233,7 +245,7 @@ class UploadButton extends React.Component { } } -interface IPollButtonProps { +interface IPollButtonProps extends Pick { room: Room; } @@ -265,10 +277,11 @@ class PollButton extends React.PureComponent { render() { return ( - ); } @@ -567,16 +580,12 @@ export default class MessageComposer extends React.Component { if (!this.state.haveRecording) { if (this.state.showPollsButton) { buttons.push( - , + , ); } uploadButtonIndex = buttons.length; buttons.push( - , + , ); if (SettingsStore.getValue("feature_location_share")) { buttons.push( @@ -610,53 +619,58 @@ export default class MessageComposer extends React.Component { />, ); } + + // XXX: the recording UI does not work well in narrow mode, so we hide this button for now if (!this.state.haveRecording && !this.state.narrowMode) { buttons.push( - this.voiceRecordingButton.current?.onRecordStartEndClick()} title={_t("Send voice message")} + narrowMode={this.state.narrowMode} />, ); } if (!this.state.narrowMode) { return buttons; - } else { - const classnames = classNames({ - mx_MessageComposer_button: true, - mx_MessageComposer_buttonMenu: true, - mx_MessageComposer_closeButtonMenu: this.state.isMenuOpen, - }); - - return <> - { buttons[uploadButtonIndex] } - - { this.state.isMenuOpen && ( - - { buttons.slice(1).map((button, index) => ( - - { button } - - )) } - - ) } - ; } + + const classnames = classNames({ + mx_MessageComposer_button: true, + mx_MessageComposer_buttonMenu: true, + mx_MessageComposer_closeButtonMenu: this.state.isMenuOpen, + }); + + // we render the uploadButton at top level as it is a very common interaction, splice it out of the rest + const [uploadButton] = buttons.splice(uploadButtonIndex, 1); + return <> + { uploadButton } + + { this.state.isMenuOpen && ( + + { buttons.map((button, index) => ( + + { button } + + )) } + + ) } + ; } render() { diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 6cc5f8ca463..363ff13427b 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -1649,7 +1649,6 @@ "Filter room members": "Filter room members", "%(userName)s (power %(powerLevelNumber)s)": "%(userName)s (power %(powerLevelNumber)s)", "Send message": "Send message", - "Emoji picker": "Emoji picker", "Add emoji": "Add emoji", "Share location": "Share location", "Upload file": "Upload file",