From 8277d78f4cd87dcb11e57a14751190b0dd9abec1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Tue, 25 Jan 2022 22:59:26 +0100 Subject: [PATCH] Quote posts: Shift+Click for normal repost MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/components/dropdown_menu.js | 14 ++++++++++---- app/soapbox/components/status_action_bar.js | 1 + .../features/status/components/action_bar.js | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/soapbox/components/dropdown_menu.js b/app/soapbox/components/dropdown_menu.js index 453f24d71..486aa0d58 100644 --- a/app/soapbox/components/dropdown_menu.js +++ b/app/soapbox/components/dropdown_menu.js @@ -220,6 +220,7 @@ export default class Dropdown extends React.PureComponent { openDropdownId: PropTypes.number, openedViaKeyboard: PropTypes.bool, text: PropTypes.string, + onShiftClick: PropTypes.func, }; static defaultProps = { @@ -230,14 +231,19 @@ export default class Dropdown extends React.PureComponent { id: id++, }; - handleClick = ({ target, type }) => { - if (this.state.id === this.props.openDropdownId) { + handleClick = e => { + const { onOpen, onShiftClick, openDropdownId } = this.props; + + if (onShiftClick && e.shiftKey) { + e.preventDefault(); + onShiftClick(e); + } else if (this.state.id === openDropdownId) { this.handleClose(); } else { - const { top } = target.getBoundingClientRect(); + const { top } = e.target.getBoundingClientRect(); const placement = top * 2 < innerHeight ? 'bottom' : 'top'; - this.props.onOpen(this.state.id, this.handleItemClick, placement, type !== 'click'); + onOpen(this.state.id, this.handleItemClick, placement, e.type !== 'click'); } } diff --git a/app/soapbox/components/status_action_bar.js b/app/soapbox/components/status_action_bar.js index 3960e6bf7..429b092ca 100644 --- a/app/soapbox/components/status_action_bar.js +++ b/app/soapbox/components/status_action_bar.js @@ -566,6 +566,7 @@ class StatusActionBar extends ImmutablePureComponent { title={!publicStatus ? intl.formatMessage(messages.cannot_reblog) : intl.formatMessage(messages.reblog)} src={reblogIcon} direction='right' + onShiftClick={this.handleReblogClick} /> ); } else { diff --git a/app/soapbox/features/status/components/action_bar.js b/app/soapbox/features/status/components/action_bar.js index e154b2d43..b34711632 100644 --- a/app/soapbox/features/status/components/action_bar.js +++ b/app/soapbox/features/status/components/action_bar.js @@ -523,6 +523,7 @@ class ActionBar extends React.PureComponent { src={reblogIcon} direction='right' text={intl.formatMessage(messages.reblog)} + onShiftClick={this.handleReblogClick} /> ); } else {