diff --git a/src/CONST.js b/src/CONST.js index 8cd797fefda2..7014aa727665 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -2315,6 +2315,10 @@ const CONST = { ACTIVE: 'active', DISABLED: 'disabled', }, + + // This ID is used in SelectionScraper.js to query the DOM for UnreadActionIndicator's + // div and then remove it from copied contents in the getHTMLOfSelection() method. + UNREAD_ACTION_INDICATOR_ID: 'no-copy-area-unread-action-indicator', }; export default CONST; diff --git a/src/components/UnreadActionIndicator.js b/src/components/UnreadActionIndicator.js index 5d671bc177d2..81cf266bef28 100755 --- a/src/components/UnreadActionIndicator.js +++ b/src/components/UnreadActionIndicator.js @@ -2,13 +2,15 @@ import React from 'react'; import {View} from 'react-native'; import styles from '../styles/styles'; import Text from './Text'; +import CONST from '../CONST'; import withLocalize, {withLocalizePropTypes} from './withLocalize'; const UnreadActionIndicator = (props) => ( {props.translate('common.new')} diff --git a/src/libs/SelectionScraper/index.js b/src/libs/SelectionScraper/index.js index 0a1174e72cfa..f4e4fcc56494 100644 --- a/src/libs/SelectionScraper/index.js +++ b/src/libs/SelectionScraper/index.js @@ -2,6 +2,7 @@ import render from 'dom-serializer'; import {parseDocument} from 'htmlparser2'; import _ from 'underscore'; import Str from 'expensify-common/lib/str'; +import CONST from '../../CONST'; const elementsWillBeSkipped = ['html', 'body']; const tagAttribute = 'data-testid'; @@ -80,6 +81,14 @@ const getHTMLOfSelection = () => { } } + // Find and remove the div housing the UnreadActionIndicator because we don't want + // the 'New/Nuevo' text inside it being copied. + const newMessageLineIndicatorDiv = div.querySelector(`#${CONST.UNREAD_ACTION_INDICATOR_ID}`); + + if (newMessageLineIndicatorDiv) { + newMessageLineIndicatorDiv.remove(); + } + return div.innerHTML; };