Skip to content

Commit

Permalink
Merge pull request #27421 from bernhardoj/fix/26694-ignore-selection
Browse files Browse the repository at this point in the history
Ignore unselectable text from selection
  • Loading branch information
Li357 authored Sep 18, 2023
2 parents 72bb058 + 113546a commit 5d4b49b
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class Button extends Component {
this.props.icon && styles.textAlignLeft,
...this.props.textStyles,
]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{this.props.text}
</Text>
Expand Down
1 change: 1 addition & 0 deletions src/components/CollapsibleSection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class CollapsibleSection extends React.Component {
<Text
selectable={false}
style={[styles.flex1, styles.textStrong]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{this.props.title}
</Text>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import _ from 'underscore';
import React from 'react';
import CONST from '../../../CONST';
import htmlRendererPropTypes from './htmlRendererPropTypes';
import withLocalize, {withLocalizePropTypes} from '../../withLocalize';
import Text from '../../Text';
Expand Down Expand Up @@ -28,6 +29,7 @@ function EditedRenderer(props) {
<Text
selectable={false}
style={[styles.w1, styles.userSelectNone]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{' '}
</Text>
Expand Down
1 change: 1 addition & 0 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ const MenuItem = React.forwardRef((props, ref) => {
<Text
style={titleTextStyle}
numberOfLines={props.numberOfLinesTitle || undefined}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: props.interactive && props.disabled}}
>
{convertToLTR(props.title)}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/components/MultipleAvatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ function MultipleAvatars(props) {
<Text
selectable={false}
style={[styles.avatarInnerTextSmall, StyleUtils.getAvatarExtraFontSizeStyle(props.size)]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>{`+${avatars.length - props.maxAvatarsInRow}`}</Text>
</View>
</View>
Expand Down Expand Up @@ -278,6 +279,7 @@ function MultipleAvatars(props) {
<Text
selectable={false}
style={props.size === CONST.AVATAR_SIZE.SMALL ? styles.avatarInnerTextSmall : styles.avatarInnerText}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{`+${props.icons.length - 1}`}
</Text>
Expand Down
7 changes: 6 additions & 1 deletion src/components/NewDatePicker/CalendarPicker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ class CalendarPicker extends React.PureComponent {

return (
<View>
<View style={[styles.calendarHeader, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ph4, styles.pr1]}>
<View
style={[styles.calendarHeader, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, styles.ph4, styles.pr1]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
<PressableWithFeedback
onPress={() => this.setState({isYearPickerVisible: true})}
style={[styles.alignItemsCenter, styles.flexRow, styles.flex1, styles.justifyContentStart]}
Expand Down Expand Up @@ -186,6 +189,7 @@ class CalendarPicker extends React.PureComponent {
<View
key={dayOfWeek}
style={[styles.calendarDayRoot, styles.flex1, styles.justifyContentCenter, styles.alignItemsCenter]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
<Text style={styles.sidebarLinkTextBold}>{dayOfWeek[0]}</Text>
</View>
Expand All @@ -212,6 +216,7 @@ class CalendarPicker extends React.PureComponent {
accessibilityLabel={day ? day.toString() : undefined}
focusable={Boolean(day)}
accessible={Boolean(day)}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{({hovered, pressed}) => (
<View
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pressable/GenericPressable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const WebGenericPressable = forwardRef((props, ref) => (
aria-labelledby={props.accessibilityLabelledBy}
aria-valuenow={props.accessibilityValue}
nativeID={props.nativeID}
dataSet={{tag: 'pressable', ...(props.noDragArea && {dragArea: false})}}
dataSet={{tag: 'pressable', ...(props.noDragArea && {dragArea: false}), ...props.dataSet}}
/>
));

Expand Down
1 change: 1 addition & 0 deletions src/components/Reactions/AddReactionBubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ function AddReactionBubble(props) {
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
// disable dimming
pressDimmingValue={1}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{({hovered, pressed}) => (
<>
Expand Down
6 changes: 4 additions & 2 deletions src/components/Reactions/EmojiReactionBubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function EmojiReactionBubble(props) {
styles.emojiReactionBubble,
StyleUtils.getEmojiReactionBubbleStyle(hovered || pressed, props.hasUserReacted, props.isContextMenu),
props.shouldBlockReactions && styles.cursorDisabled,
styles.userSelectNone,
]}
onPress={() => {
if (props.shouldBlockReactions) {
Expand All @@ -83,9 +84,10 @@ function EmojiReactionBubble(props) {
}}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
accessibilityLabel={props.emojiCodes.join('')}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
<Text style={[styles.emojiReactionBubbleText, styles.userSelectNone, StyleUtils.getEmojiReactionBubbleTextStyle(props.isContextMenu)]}>{props.emojiCodes.join('')}</Text>
{props.count > 0 && <Text style={[styles.reactionCounterText, styles.userSelectNone, StyleUtils.getEmojiReactionCounterTextStyle(props.hasUserReacted)]}>{props.count}</Text>}
<Text style={[styles.emojiReactionBubbleText, StyleUtils.getEmojiReactionBubbleTextStyle(props.isContextMenu)]}>{props.emojiCodes.join('')}</Text>
{props.count > 0 && <Text style={[styles.reactionCounterText, StyleUtils.getEmojiReactionCounterTextStyle(props.hasUserReacted)]}>{props.count}</Text>}
</PressableWithSecondaryInteraction>
);
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/Reactions/MiniQuickEmojiReactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,12 @@ function MiniQuickEmojiReactions(props) {
tooltipText={`:${EmojiUtils.getLocalizedEmojiName(emoji.name, props.preferredLocale)}:`}
onPress={Session.checkIfActionIsAllowed(() => props.onEmojiSelected(emoji, props.emojiReactions))}
>
<Text style={[styles.miniQuickEmojiReactionText, styles.userSelectNone]}>{EmojiUtils.getPreferredEmojiCode(emoji, props.preferredSkinTone)}</Text>
<Text
style={[styles.miniQuickEmojiReactionText, styles.userSelectNone]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{EmojiUtils.getPreferredEmojiCode(emoji, props.preferredSkinTone)}
</Text>
</BaseMiniContextMenuItem>
))}
<BaseMiniContextMenuItem
Expand Down
1 change: 1 addition & 0 deletions src/components/SelectionList/BaseSelectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ function BaseSelectionList({
accessibilityRole="button"
accessibilityState={{checked: flattenedSections.allSelected}}
disabled={flattenedSections.allOptions.length === flattenedSections.disabledOptionsIndexes.length}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
<Checkbox
accessibilityLabel={translate('workspace.people.selectAll')}
Expand Down
2 changes: 2 additions & 0 deletions src/components/SelectionList/RadioListItem.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import {View} from 'react-native';
import CONST from '../../CONST';
import PressableWithFeedback from '../Pressable/PressableWithFeedback';
import styles from '../../styles/styles';
import Text from '../Text';
Expand All @@ -18,6 +19,7 @@ function RadioListItem({item, isFocused = false, isDisabled = false, onSelectRow
hoverDimmingValue={1}
hoverStyle={styles.hoveredComponentBG}
focusStyle={styles.hoveredComponentBG}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
<View style={[styles.flex1, styles.justifyContentBetween, styles.sidebarLinkInner, styles.optionRow, styles.userSelectNone, isFocused && styles.sidebarLinkActive]}>
<View style={[styles.flex1, styles.alignItemsStart]}>
Expand Down
1 change: 1 addition & 0 deletions src/components/SelectionList/UserListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function UserListItem({item, isFocused = false, showTooltip, onSelectRow, onDism
hoverDimmingValue={1}
hoverStyle={styles.hoveredComponentBG}
focusStyle={styles.hoveredComponentBG}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
<View style={styles.checkboxPressable}>
<View
Expand Down
1 change: 1 addition & 0 deletions src/components/TextInput/BaseTextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ function BaseTextInput(props) {
pointerEvents="none"
selectable={false}
style={[styles.textInputPrefix, !hasLabel && styles.pv0]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{props.prefixCharacter}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/FloatingMessageCounter/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {useEffect, useMemo, useCallback} from 'react';
import {Animated, View} from 'react-native';
import PropTypes from 'prop-types';
import CONST from '../../../../CONST';
import styles from '../../../../styles/styles';
import Button from '../../../../components/Button';
import Text from '../../../../components/Text';
Expand Down Expand Up @@ -76,6 +77,7 @@ function FloatingMessageCounter(props) {
<Text
selectable={false}
style={[styles.ml2, styles.buttonSmallText, styles.textWhite]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{translate('newMessages')}
</Text>
Expand Down
1 change: 1 addition & 0 deletions src/pages/home/report/ReportActionItemFragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function ReportActionItemFragment(props) {
<Text
selectable={false}
style={[containsOnlyEmojis ? styles.onlyEmojisTextLineHeight : undefined, styles.w1, styles.userSelectNone]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{' '}
</Text>
Expand Down
2 changes: 2 additions & 0 deletions src/pages/home/report/ReportActionItemThread.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ function ReportActionItemThread(props) {
<Text
selectable={false}
style={[styles.link, styles.ml2, styles.h4, styles.noWrap]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{`${numberOfRepliesText} ${replyText}`}
</Text>
<Text
selectable={false}
numberOfLines={1}
style={[styles.ml2, styles.textMicroSupporting, styles.flex1]}
dataSet={{[CONST.SELECTION_SCRAPER_HIDDEN_ELEMENT]: true}}
>
{timeStamp}
</Text>
Expand Down

0 comments on commit 5d4b49b

Please sign in to comment.