Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preventing from copying contents of the Mini Report Action Context Menu #19518

Merged
merged 2 commits into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/CONST.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
// 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',
MODERATOR_DECISION_PENDING_HIDE: 'pendingHide',
Expand Down
2 changes: 1 addition & 1 deletion src/components/UnreadActionIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
>
<View style={styles.unreadIndicatorLine} />
<Text style={styles.unreadIndicatorText}>{props.translate('common.new')}</Text>
Expand Down
8 changes: 5 additions & 3 deletions src/libs/SelectionScraper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']),
Expand All @@ -20,7 +21,10 @@ const defaultProps = {
};

const MiniReportActionContextMenu = (props) => (
<View style={StyleUtils.getMiniReportActionContextMenuWrapperStyle(props.displayAsGroup)}>
<View
style={StyleUtils.getMiniReportActionContextMenuWrapperStyle(props.displayAsGroup)}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: props.isVisible}}
>
<BaseReportActionContextMenu
isMini
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down