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

[No QA] Console error cleanup pt3 #55066

Merged
merged 48 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
4afa549
fix console errors on moneyrequestconfirmation page and submit expense
kubabutkiewicz Jan 9, 2025
a4eb650
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 9, 2025
1af473b
continue fixing console errors
kubabutkiewicz Jan 9, 2025
463cdac
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 10, 2025
dcc41ce
fix console error related to workletization
kubabutkiewicz Jan 13, 2025
80bc6a0
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 13, 2025
e1d00a0
fix console error regarding gesture handler
kubabutkiewicz Jan 13, 2025
867277a
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 14, 2025
20f2455
fix nested buttons console error in avatarwithdisplayname
kubabutkiewicz Jan 15, 2025
de99950
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 15, 2025
5f69616
fix console errors regarding nested buttons, not using forwardRef and…
kubabutkiewicz Jan 16, 2025
614f72f
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 16, 2025
901b8fc
fix lint problems
kubabutkiewicz Jan 16, 2025
8e7edb9
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 16, 2025
b146b4c
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 20, 2025
88c99f4
fix: error about nested buttons in html
kubabutkiewicz Jan 21, 2025
8cb2190
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 21, 2025
8bd65b0
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 22, 2025
7b7d70b
fix nested button in html on search page
kubabutkiewicz Jan 22, 2025
d5e336b
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 22, 2025
91b8885
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 22, 2025
61a5a23
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 23, 2025
522c25f
fix: resolved comments
kubabutkiewicz Jan 23, 2025
0511174
fix: tests
kubabutkiewicz Jan 23, 2025
c44be38
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 24, 2025
13137cb
fix: resolve comments
kubabutkiewicz Jan 24, 2025
75ad3d2
fix missing key in map
kubabutkiewicz Jan 24, 2025
8b958f2
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 24, 2025
033f142
fix lint
kubabutkiewicz Jan 24, 2025
5b4bf77
fix nested buttons on Workspace settings
kubabutkiewicz Jan 27, 2025
639af68
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Jan 31, 2025
44c8505
fix nested buttons errors
kubabutkiewicz Jan 31, 2025
6b09c1b
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 3, 2025
42ede38
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 3, 2025
f763a81
fix missing key prop
kubabutkiewicz Feb 3, 2025
dcf5f16
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 4, 2025
0654558
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 5, 2025
a298ed4
fix nested buttons warning
kubabutkiewicz Feb 5, 2025
abd80c3
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 5, 2025
fed8e47
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 6, 2025
0ad061d
fix error ref.measureLayout need to be called with native component
kubabutkiewicz Feb 6, 2025
684523b
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 7, 2025
4e2e693
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 11, 2025
8532314
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 11, 2025
85c80bf
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 13, 2025
7289ce9
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 14, 2025
c6577f1
Merge branch 'main' of github.com:callstack-internal/Expensify-App in…
kubabutkiewicz Feb 18, 2025
dbe79e7
fix typos
kubabutkiewicz Feb 18, 2025
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/node_modules/react-native-draggable-flatlist/src/components/NestableDraggableFlatList.tsx b/node_modules/react-native-draggable-flatlist/src/components/NestableDraggableFlatList.tsx
index 1559352..b84ee99 100644
--- a/node_modules/react-native-draggable-flatlist/src/components/NestableDraggableFlatList.tsx
+++ b/node_modules/react-native-draggable-flatlist/src/components/NestableDraggableFlatList.tsx
@@ -56,6 +56,11 @@ function NestableDraggableFlatListInner<T>(
const onFail = () => {
console.log("## nested draggable list measure fail");
};
+
+ if (typeof nodeHandle === "number" ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you explain about this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+ return;
+ }
+
//@ts-ignore
containerRef.current.measureLayout(nodeHandle, onSuccess, onFail);
});
33 changes: 18 additions & 15 deletions src/components/AvatarWithDisplayName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {Policy, Report} from '@src/types/onyx';
import type {Icon} from '@src/types/onyx/OnyxCommon';
import {getButtonRole} from './Button/utils';
import CaretWrapper from './CaretWrapper';
import DisplayNames from './DisplayNames';
import {FallbackAvatar} from './Icon/Expensicons';
Expand Down Expand Up @@ -134,22 +135,24 @@ function AvatarWithDisplayName({policy, report, isAnonymous = false, size = CONS
<PressableWithoutFeedback
onPress={showActorDetails}
accessibilityLabel={title}
role={CONST.ROLE.BUTTON}
role={getButtonRole(true)}
>
{shouldShowSubscriptAvatar ? (
<SubscriptAvatar
backgroundColor={avatarBorderColor}
mainAvatar={icons.at(0) ?? fallbackIcon}
secondaryAvatar={icons.at(1)}
size={size}
/>
) : (
<MultipleAvatars
icons={icons}
size={size}
secondAvatarStyle={[StyleUtils.getBackgroundAndBorderStyle(avatarBorderColor)]}
/>
)}
<View accessibilityLabel={title}>
{shouldShowSubscriptAvatar ? (
<SubscriptAvatar
backgroundColor={avatarBorderColor}
mainAvatar={icons.at(0) ?? fallbackIcon}
secondaryAvatar={icons.at(1)}
size={size}
/>
) : (
<MultipleAvatars
icons={icons}
size={size}
secondAvatarStyle={[StyleUtils.getBackgroundAndBorderStyle(avatarBorderColor)]}
/>
)}
</View>
</PressableWithoutFeedback>
<View style={[styles.flex1, styles.flexColumn]}>
<CaretWrapper>
Expand Down
9 changes: 7 additions & 2 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import HapticFeedback from '@libs/HapticFeedback';
import CONST from '@src/CONST';
import type ChildrenProps from '@src/types/utils/ChildrenProps';
import type IconAsset from '@src/types/utils/IconAsset';
import {getButtonRole, getButtonStyle} from './utils';
import validateSubmitShortcut from './validateSubmitShortcut';

type ButtonProps = Partial<ChildrenProps> & {
Expand Down Expand Up @@ -146,6 +147,9 @@ type ButtonProps = Partial<ChildrenProps> & {
/** Whether the Enter keyboard listening is active whether or not the screen that contains the button is focused */
isPressOnEnterActive?: boolean;

/** Whether is a nested button inside other button, since nesting buttons isn't valid html */
isNested?: boolean;

/** The text displays under the first line */
secondLineText?: string;
};
Expand Down Expand Up @@ -249,6 +253,7 @@ function Button(
link = false,
isContentCentered = false,
isPressOnEnterActive,
isNested = false,
secondLineText = '',
...rest
}: ButtonProps,
Expand Down Expand Up @@ -414,10 +419,10 @@ function Button(
isDisabled && !danger && !success ? styles.buttonDisabled : undefined,
shouldRemoveRightBorderRadius ? styles.noRightBorderRadius : undefined,
shouldRemoveLeftBorderRadius ? styles.noLeftBorderRadius : undefined,
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
text && shouldShowRightIcon ? styles.alignItemsStretch : undefined,
innerStyles,
link && styles.bgTransparent,
getButtonStyle(styles, isNested),
]}
hoverStyle={[
shouldUseDefaultHover && !isDisabled ? styles.buttonDefaultHovered : undefined,
Expand All @@ -429,7 +434,7 @@ function Button(
id={id}
testID={testID}
accessibilityLabel={accessibilityLabel}
role={CONST.ROLE.BUTTON}
role={getButtonRole(isNested)}
hoverDimmingValue={1}
onHoverIn={() => setIsHovered(true)}
onHoverOut={() => setIsHovered(false)}
Expand Down
6 changes: 6 additions & 0 deletions src/components/Button/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import CONST from '@src/CONST';
import type {GetButtonRole, GetButtonStyle} from './types';

const getButtonStyle: GetButtonStyle = () => undefined;
const getButtonRole: GetButtonRole = () => CONST.ROLE.BUTTON;
export {getButtonStyle, getButtonRole};
7 changes: 7 additions & 0 deletions src/components/Button/utils/index.web.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import CONST from '@src/CONST';
import type {GetButtonRole, GetButtonStyle} from './types';

const getButtonStyle: GetButtonStyle = (styles, isNested) => (isNested ? styles.cursorPointer : undefined);
const getButtonRole: GetButtonRole = (isNested) => (isNested ? CONST.ROLE.PRESENTATION : CONST.ROLE.BUTTON);

export {getButtonStyle, getButtonRole};
7 changes: 7 additions & 0 deletions src/components/Button/utils/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type {Role, StyleProp, ViewStyle} from 'react-native';

type GetButtonStyle = (styles: {cursorPointer: ViewStyle}, isNested: boolean) => StyleProp<ViewStyle> | undefined;

type GetButtonRole = (isNested: boolean) => Role | undefined;

export type {GetButtonStyle, GetButtonRole};
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ function DeletedActionRenderer({tnode}: CustomRendererProps<TText | TPhrasing>)
const data = firstChild && 'data' in firstChild ? firstChild.data : null;

if (typeof data === 'string') {
return <Text style={(styles.textLabelSupporting, styles.textStrong)}>{data}</Text>;
return (
<Text
key={data}
style={(styles.textLabelSupporting, styles.textStrong)}
>
{data}
</Text>
);
}
return props.childElement;
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {useOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import type {CustomRendererProps, TBlock} from 'react-native-render-html';
import {AttachmentContext} from '@components/AttachmentContext';
import {getButtonRole, getButtonStyle} from '@components/Button/utils';
import {isDeletedNode} from '@components/HTMLEngineProvider/htmlEngineUtils';
import * as Expensicons from '@components/Icon/Expensicons';
import PressableWithoutFocus from '@components/Pressable/PressableWithoutFocus';
Expand All @@ -11,9 +12,9 @@ import ThumbnailImage from '@components/ThumbnailImage';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as FileUtils from '@libs/fileDownload/FileUtils';
import {getFileName, getFileType, splitExtensionFromFileName} from '@libs/fileDownload/FileUtils';
import Navigation from '@libs/Navigation/Navigation';
import * as ReportUtils from '@libs/ReportUtils';
import {isArchivedNonExpenseReport} from '@libs/ReportUtils';
import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
Expand Down Expand Up @@ -70,12 +71,12 @@ function ImageRenderer({tnode}: ImageRendererProps) {
const imageHeight = (htmlAttribs['data-expensify-height'] && parseInt(htmlAttribs['data-expensify-height'], 10)) || undefined;
const imagePreviewModalDisabled = htmlAttribs['data-expensify-preview-modal-disabled'] === 'true';

const fileType = FileUtils.getFileType(attachmentSourceAttribute);
const fileType = getFileType(attachmentSourceAttribute);
const fallbackIcon = fileType === CONST.ATTACHMENT_FILE_TYPE.FILE ? Expensicons.Document : Expensicons.GalleryNotFound;
const theme = useTheme();

let fileName = htmlAttribs[CONST.ATTACHMENT_ORIGINAL_FILENAME_ATTRIBUTE] || FileUtils.getFileName(`${isAttachmentOrReceipt ? attachmentSourceAttribute : htmlAttribs.src}`);
const fileInfo = FileUtils.splitExtensionFromFileName(fileName);
let fileName = htmlAttribs[CONST.ATTACHMENT_ORIGINAL_FILENAME_ATTRIBUTE] || getFileName(`${isAttachmentOrReceipt ? attachmentSourceAttribute : htmlAttribs.src}`);
const fileInfo = splitExtensionFromFileName(fileName);
if (!fileInfo.fileExtension) {
fileName = `${fileInfo?.fileName || CONST.DEFAULT_IMAGE_FILE_NAME}.jpg`;
}
Expand Down Expand Up @@ -103,7 +104,7 @@ function ImageRenderer({tnode}: ImageRendererProps) {
<AttachmentContext.Consumer>
{({reportID, accountID, type}) => (
<PressableWithoutFocus
style={[styles.noOutline]}
style={[styles.noOutline, getButtonStyle(styles, true)]}
onPress={() => {
if (!source || !type) {
return;
Expand All @@ -117,17 +118,10 @@ function ImageRenderer({tnode}: ImageRendererProps) {
if (isDisabled) {
return;
}
showContextMenuForReport(
event,
anchor,
report?.reportID,
action,
checkIfContextMenuActive,
ReportUtils.isArchivedNonExpenseReport(report, reportNameValuePairs),
);
showContextMenuForReport(event, anchor, report?.reportID, action, checkIfContextMenuActive, isArchivedNonExpenseReport(report, reportNameValuePairs));
}}
shouldUseHapticsOnLongPress
accessibilityRole={CONST.ROLE.BUTTON}
role={getButtonRole(true)}
accessibilityLabel={translate('accessibilityHints.viewAttachment')}
>
{thumbnailImageComponent}
Expand Down
54 changes: 27 additions & 27 deletions src/components/MoneyRequestConfirmationListFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -328,33 +328,33 @@ function MoneyRequestConfirmationListFooter({
},
{
item: (
<ShowContextMenuContext.Provider value={contextMenuContextValue}>
<MentionReportContext.Provider
key={translate('common.description')}
value={mentionReportContextValue}
>
<MenuItemWithTopDescription
key={translate('common.description')}
shouldShowRightIcon={!isReadOnly}
shouldParseTitle
excludedMarkdownRules={!policy ? ['reportMentions'] : []}
title={iouComment}
description={translate('common.description')}
onPress={() => {
if (!transactionID) {
return;
}

Navigation.navigate(ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRoute(), reportActionID));
}}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
disabled={didConfirm}
interactive={!isReadOnly}
numberOfLinesTitle={2}
/>
</MentionReportContext.Provider>
</ShowContextMenuContext.Provider>
<View key={translate('common.description')}>
<ShowContextMenuContext.Provider value={contextMenuContextValue}>
<MentionReportContext.Provider value={mentionReportContextValue}>
<MenuItemWithTopDescription
shouldShowRightIcon={!isReadOnly}
shouldParseTitle
excludedMarkdownRules={!policy ? ['reportMentions'] : []}
title={iouComment}
description={translate('common.description')}
onPress={() => {
if (!transactionID) {
return;
}

Navigation.navigate(
ROUTES.MONEY_REQUEST_STEP_DESCRIPTION.getRoute(action, iouType, transactionID, reportID, Navigation.getActiveRoute(), reportActionID),
);
}}
style={[styles.moneyRequestMenuItem]}
titleStyle={styles.flex1}
disabled={didConfirm}
interactive={!isReadOnly}
numberOfLinesTitle={2}
/>
</MentionReportContext.Provider>
</ShowContextMenuContext.Provider>
</View>
),
shouldShow: true,
isSupplementary: false,
Expand Down
2 changes: 2 additions & 0 deletions src/components/MultiGestureCanvas/usePinchGesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ const usePinchGesture = ({
pinchOrigin.y.set(adjustedFocal.y);
})
.onChange((evt) => {
'worklet';

// Disable the pinch gesture if one finger is released,
// to prevent the content from shaking/jumping
if (evt.numberOfPointers !== 2) {
Expand Down
8 changes: 8 additions & 0 deletions src/components/MultiGestureCanvas/useTapGestures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ const useTapGestures = ({
const doubleTapGesture = Gesture.Tap()
// The first argument is not used, but must be defined
.onTouchesDown((_evt, state) => {
'worklet';

if (!shouldDisableTransformationGestures.get()) {
return;
}
Expand All @@ -132,6 +134,8 @@ const useTapGestures = ({
.maxDelay(150)
.maxDistance(20)
.onEnd((evt) => {
'worklet';

const triggerScaleChangedEvent = () => {
'worklet';

Expand All @@ -153,9 +157,13 @@ const useTapGestures = ({
.numberOfTaps(1)
.maxDuration(125)
.onBegin(() => {
'worklet';

stopAnimation();
})
.onFinalize((_evt, success) => {
'worklet';

if (!success || onTap === undefined) {
return;
}
Expand Down
14 changes: 13 additions & 1 deletion src/components/ReceiptAudit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,19 @@ function ReceiptAudit({notes, shouldShowAuditResult}: ReceiptAuditProps) {

function ReceiptAuditMessages({notes = []}: {notes?: string[]}) {
const styles = useThemeStyles();
return <View style={[styles.mtn1, styles.mb2, styles.ph5, styles.gap1]}>{notes.length > 0 && notes.map((message) => <Text style={[styles.textLabelError]}>{message}</Text>)}</View>;
return (
<View style={[styles.mtn1, styles.mb2, styles.ph5, styles.gap1]}>
{notes.length > 0 &&
notes.map((message) => (
<Text
style={[styles.textLabelError]}
key={message}
>
{message}
</Text>
))}
</View>
);
}

export {ReceiptAuditMessages};
Expand Down
15 changes: 13 additions & 2 deletions src/components/ReferralProgramCTA.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import CONST from '@src/CONST';
import Navigation from '@src/libs/Navigation/Navigation';
import ROUTES from '@src/ROUTES';
import {getButtonRole, getButtonStyle} from './Button/utils';
import Icon from './Icon';
import {Close} from './Icon/Expensicons';
import {PressableWithoutFeedback} from './Pressable';
Expand Down Expand Up @@ -52,9 +53,19 @@ function ReferralProgramCTA({referralContentType, style, onDismiss}: ReferralPro
onPress={() => {
Navigation.navigate(ROUTES.REFERRAL_DETAILS_MODAL.getRoute(referralContentType, Navigation.getActiveRouteWithoutParams()));
}}
style={[styles.br2, styles.highlightBG, styles.flexRow, styles.justifyContentBetween, styles.alignItemsCenter, {gap: 10, padding: 10}, styles.pl5, style]}
style={[
styles.br2,
styles.highlightBG,
styles.flexRow,
styles.justifyContentBetween,
styles.alignItemsCenter,
{gap: 10, padding: 10},
styles.pl5,
getButtonStyle(styles, true),
style,
]}
accessibilityLabel="referral"
role={CONST.ROLE.BUTTON}
role={getButtonRole(true)}
>
<Text>
{translate(`referralProgram.${referralContentType}.buttonText1`)}
Expand Down
10 changes: 5 additions & 5 deletions src/components/ReportActionItem/ReportActionItemImages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ function ReportActionItemImages({images, size, total, isHovered = false, onPress
const shouldShowBorder = shownImages.length > 1 && index < shownImages.length - 1;
const borderStyle = shouldShowBorder ? styles.reportActionItemImageBorder : {};
return (
<ImageBehaviorContextProvider shouldSetAspectRatioInStyle={numberOfShownImages === 1 ? true : Str.isPDF(filename ?? '')}>
<View
key={`${index}-${image}`}
style={[styles.reportActionItemImage, borderStyle, hoverStyle]}
>
<ImageBehaviorContextProvider
key={`${index}-${image}`}
shouldSetAspectRatioInStyle={numberOfShownImages === 1 ? true : Str.isPDF(filename ?? '')}
>
<View style={[styles.reportActionItemImage, borderStyle, hoverStyle]}>
<ReportActionItemImage
thumbnail={thumbnail}
fileExtension={fileExtension}
Expand Down
Loading
Loading