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

Fix suggestion overlay #47992

Merged
merged 4 commits into from
Aug 30, 2024
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useCallback} from 'react';
import React, {useCallback, useMemo} from 'react';
import {View} from 'react-native';
import type {PointerEvent} from 'react-native';
import type PressableProps from '@components/Pressable/GenericPressable/types';
Expand Down Expand Up @@ -29,14 +29,23 @@ function TransparentOverlay({onPress: onPressProp}: TransparentOverlayProps) {
e?.preventDefault();
}, []);

// The overlay is a semi-transparent layer that covers the entire screen and is used to close a modal when clicked.
// The touch event passes through the transparent overlay to the elements underneath, so we need to prevent that by adding a nearly invisible background color to the overlay.
const overlay = useMemo(
() => ({
backgroundColor: 'rgba(0, 0, 0, 0.005)',
}),
[],
);

Comment on lines +34 to +39
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not declare this in styles ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to put this in the styles constant because it feels a bit hacky. Plus, we usually avoid inline styling in the render method since it's not the best practice

Copy link
Contributor

@ishpaul777 ishpaul777 Aug 29, 2024

Choose a reason for hiding this comment

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

Okay, can you please just add comment above it about why are we doing it like this.

Copy link
Contributor

Choose a reason for hiding this comment

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

@perunt bump ^

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure 👍🏻

return (
<View
onPointerDown={handlePointerDown}
style={styles.fullScreen}
>
<PressableWithoutFeedback
onPress={onPress}
style={[styles.flex1, styles.cursorDefault]}
style={[styles.flex1, styles.cursorDefault, overlay]}
accessibilityLabel={translate('common.close')}
role={CONST.ROLE.BUTTON}
/>
Expand Down
Loading