From 269f1f33e337584ccb85861348abb8b4ff58b2f5 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 6 Sep 2017 11:27:25 +0100 Subject: [PATCH] show response on copy so you don't mash it Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/messages/TextualBody.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index 58273bee67..a0fa61ccca 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -31,6 +31,7 @@ import dis from '../../../dispatcher'; import { _t } from '../../../languageHandler'; import UserSettingsStore from "../../../UserSettingsStore"; import MatrixClientPeg from '../../../MatrixClientPeg'; +import ContextualMenu from '../../structures/ContextualMenu'; import {RoomMember} from 'matrix-js-sdk'; import classNames from 'classnames'; @@ -119,6 +120,20 @@ module.exports = React.createClass({ buttons[i].onclick = (e) => { const copyCode = buttons[i].parentNode.getElementsByTagName("code")[0]; this.copyToClipboard(copyCode.textContent); + + const GenericTextContextMenu = sdk.getComponent('context_menus.GenericTextContextMenu'); + const buttonRect = e.target.getBoundingClientRect(); + + // The window X and Y offsets are to adjust position when zoomed in to page + const x = buttonRect.right + window.pageXOffset; + const y = (buttonRect.top + (buttonRect.height / 2) + window.pageYOffset) - 19; + const {close} = ContextualMenu.createMenu(GenericTextContextMenu, { + chevronOffset: 10, + left: x, + top: y, + message: "Copied!", + }); + e.target.onmouseout = close; }; } }