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

20023 - migrated ReportActionItemMessageEdit to PressableWithFeedback #20082

Merged
Merged
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
56 changes: 28 additions & 28 deletions src/pages/home/report/ReportActionItemMessageEdit.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable rulesdir/onyx-props-must-have-default */
import lodashGet from 'lodash/get';
import React from 'react';
// eslint-disable-next-line no-restricted-imports
import {InteractionManager, Keyboard, Pressable, TouchableOpacity, View} from 'react-native';
import {InteractionManager, Keyboard, View} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
Expand All @@ -24,7 +23,6 @@ import Tooltip from '../../../components/Tooltip';
import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu';
import * as ReportUtils from '../../../libs/ReportUtils';
import * as EmojiUtils from '../../../libs/EmojiUtils';
import getButtonState from '../../../libs/getButtonState';
import reportPropTypes from '../../reportPropTypes';
import ExceededCommentLength from '../../../components/ExceededCommentLength';
import CONST from '../../../CONST';
Expand All @@ -35,6 +33,8 @@ import refPropTypes from '../../../components/refPropTypes';
import * as ComposerUtils from '../../../libs/ComposerUtils';
import * as ComposerActions from '../../../libs/actions/Composer';
import * as User from '../../../libs/actions/User';
import PressableWithFeedback from '../../../components/Pressable/PressableWithFeedback';
import Hoverable from '../../../components/Hoverable';

const propTypes = {
/** All the data of the action */
Expand Down Expand Up @@ -279,24 +279,26 @@ class ReportActionItemMessageEdit extends React.Component {
<View style={[styles.chatItemMessage, styles.flexRow]}>
<View style={[styles.justifyContentEnd]}>
<Tooltip text={this.props.translate('common.cancel')}>
<Pressable
style={({hovered, pressed}) => [styles.chatItemSubmitButton, StyleUtils.getButtonBackgroundColorStyle(getButtonState(hovered, pressed))]}
nativeID={this.cancelButtonID}
onPress={this.deleteDraft}
hitSlop={{
top: 3,
right: 3,
bottom: 3,
left: 3,
}}
>
{({hovered, pressed}) => (
<Icon
src={Expensicons.Close}
fill={StyleUtils.getIconFillColor(getButtonState(hovered, pressed))}
/>
<Hoverable>
Copy link
Contributor

@0xmiros 0xmiros Jul 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming from #21248:
Wrapping redundant Hoverable here caused regression of tooltip not showing on Cancel button.
More details about the root cause - #21248 (comment).
We could have simply used PressableWithFeedback's function child which supports hovered prop.

{(hovered) => (
<PressableWithFeedback
onPress={this.deleteDraft}
style={styles.chatItemSubmitButton}
accessibilityRole="button"
accessibilityLabel={this.props.translate('common.close')}
// disable dimming
hoverDimmingValue={1}
pressDimmingValue={1}
hoverStyle={StyleUtils.getButtonBackgroundColorStyle(CONST.BUTTON_STATES.ACTIVE)}
pressStyle={StyleUtils.getButtonBackgroundColorStyle(CONST.BUTTON_STATES.PRESSED)}
>
<Icon
src={Expensicons.Close}
fill={StyleUtils.getIconFillColor(hovered ? CONST.BUTTON_STATES.ACTIVE : CONST.BUTTON_STATES.DEFAULT)}
/>
</PressableWithFeedback>
)}
</Pressable>
</Hoverable>
</Tooltip>
</View>
<View
Expand Down Expand Up @@ -355,23 +357,21 @@ class ReportActionItemMessageEdit extends React.Component {

<View style={styles.alignSelfEnd}>
<Tooltip text={this.props.translate('common.saveChanges')}>
<TouchableOpacity
<PressableWithFeedback
style={[styles.chatItemSubmitButton, hasExceededMaxCommentLength ? {} : styles.buttonSuccess]}
onPress={this.publishDraft}
hitSlop={{
top: 3,
right: 3,
bottom: 3,
left: 3,
}}
nativeID={this.saveButtonID}
disabled={hasExceededMaxCommentLength}
accessibilityRole="button"
accessibilityLabel={this.props.translate('common.saveChanges')}
hoverDimmingValue={1}
pressDimmingValue={0.2}
>
<Icon
src={Expensicons.Checkmark}
fill={hasExceededMaxCommentLength ? themeColors.icon : themeColors.textLight}
/>
</TouchableOpacity>
</PressableWithFeedback>
</Tooltip>
</View>
</View>
Expand Down