From 9829c2564c71ab3081ee21c1b69bc2ffcf2361c1 Mon Sep 17 00:00:00 2001 From: burczu Date: Tue, 16 May 2023 12:41:12 +0200 Subject: [PATCH 1/2] draft solution added --- src/CONST.js | 6 +++--- src/components/UnreadActionIndicator.js | 2 +- src/libs/SelectionScraper/index.js | 8 +++++--- .../ContextMenu/MiniReportActionContextMenu/index.js | 6 +++++- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index 182548b4d99e..fce6ca2cb870 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -2426,9 +2426,9 @@ const CONST = { }, SPACE_CHARACTER_WIDTH: 4, - // 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', + // This attribute is used in SelectionScraper.js to query the DOM elements + // and then remove them from copied contents in the getHTMLOfSelection() method. + SELECTION_SCRAPER_HIDDEN_ELEMENT: 'selection-scrapper-hidden-element', MODERATION: { MODERATOR_DECISION_PENDING: 'pending', MODERATOR_DECISION_PENDING_HIDE: 'pendingHide', diff --git a/src/components/UnreadActionIndicator.js b/src/components/UnreadActionIndicator.js index 81cf266bef28..0d45c90aa441 100755 --- a/src/components/UnreadActionIndicator.js +++ b/src/components/UnreadActionIndicator.js @@ -10,7 +10,7 @@ const UnreadActionIndicator = (props) => ( accessibilityLabel={props.translate('accessibilityHints.newMessageLineIndicator')} data-action-id={props.reportActionID} style={[styles.unreadIndicatorContainer, styles.userSelectNone]} - nativeID={CONST.UNREAD_ACTION_INDICATOR_ID} + dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}} > {props.translate('common.new')} diff --git a/src/libs/SelectionScraper/index.js b/src/libs/SelectionScraper/index.js index aab5ca78e4ed..44b87deba796 100644 --- a/src/libs/SelectionScraper/index.js +++ b/src/libs/SelectionScraper/index.js @@ -83,10 +83,12 @@ 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}`); + const divsToRemove = div.querySelectorAll(`[data-${CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT}=true]`); - if (newMessageLineIndicatorDiv) { - newMessageLineIndicatorDiv.remove(); + if (divsToRemove && divsToRemove.length > 0) { + divsToRemove.forEach((element) => { + element.remove(); + }); } return div.innerHTML; diff --git a/src/pages/home/report/ContextMenu/MiniReportActionContextMenu/index.js b/src/pages/home/report/ContextMenu/MiniReportActionContextMenu/index.js index f2883acc3b95..2c0f2ff65561 100644 --- a/src/pages/home/report/ContextMenu/MiniReportActionContextMenu/index.js +++ b/src/pages/home/report/ContextMenu/MiniReportActionContextMenu/index.js @@ -5,6 +5,7 @@ import PropTypes from 'prop-types'; import {propTypes as genericReportActionContextMenuPropTypes, defaultProps as GenericReportActionContextMenuDefaultProps} from '../genericReportActionContextMenuPropTypes'; import * as StyleUtils from '../../../../../styles/StyleUtils'; import BaseReportActionContextMenu from '../BaseReportActionContextMenu'; +import CONST from '../../../../../CONST'; const propTypes = { ..._.omit(genericReportActionContextMenuPropTypes, ['isMini']), @@ -20,7 +21,10 @@ const defaultProps = { }; const MiniReportActionContextMenu = (props) => ( - + Date: Thu, 25 May 2023 13:17:05 +0200 Subject: [PATCH 2/2] const comment amended --- src/CONST.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/CONST.js b/src/CONST.js index fce6ca2cb870..0b8ddda47d86 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -2426,8 +2426,8 @@ const CONST = { }, SPACE_CHARACTER_WIDTH: 4, - // This attribute is used in SelectionScraper.js to query the DOM elements - // and then remove them from copied contents in the getHTMLOfSelection() method. + // The attribute used in the SelectionScraper.js helper to query all the DOM elements + // that should be removed from the copied contents in the getHTMLOfSelection() method SELECTION_SCRAPER_HIDDEN_ELEMENT: 'selection-scrapper-hidden-element', MODERATION: { MODERATOR_DECISION_PENDING: 'pending',