Skip to content

Commit

Permalink
Merge pull request #51795 from Expensify/michal-revert-nkdengineer/fi…
Browse files Browse the repository at this point in the history
…x/50779

[CP Staging] Revert "Merge pull request #51158 from nkdengineer/fix/50779"

(cherry picked from commit 9406610)

(CP triggered by Beamanator)
  • Loading branch information
mountiny authored and OSBotify committed Nov 1, 2024
1 parent ce0e4c1 commit aff5b6a
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 34 deletions.
5 changes: 0 additions & 5 deletions src/components/AttachmentPicker/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager';
import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import * as FileUtils from '@libs/fileDownload/FileUtils';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -118,8 +116,6 @@ function AttachmentPicker({
fileLimit = 1,
}: AttachmentPickerProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const theme = useTheme();
const [isVisible, setIsVisible] = useState(false);

const completeAttachmentSelection = useRef<(data: FileObject[]) => void>(() => {});
Expand Down Expand Up @@ -448,7 +444,6 @@ function AttachmentPicker({
title={translate(item.textTranslationKey)}
onPress={() => selectItem(item)}
focused={focusedIndex === menuIndex}
wrapperStyle={StyleUtils.getItemBackgroundColorStyle(false, focusedIndex === menuIndex, theme.activeComponentBG, theme.hoverComponentBG)}
/>
))}
</View>
Expand Down
3 changes: 2 additions & 1 deletion src/components/EmojiPicker/EmojiPickerMenuItem/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ function EmojiPickerMenuItem({
ref.current = el ?? null;
}}
style={({pressed}) => [
isFocused || isHovered || isHighlighted ? themeStyles.emojiItemHighlighted : {},
isFocused ? themeStyles.emojiItemKeyboardHighlighted : {},
isHovered || isHighlighted ? themeStyles.emojiItemHighlighted : {},
Browser.isMobile() && StyleUtils.getButtonBackgroundColorStyle(getButtonState(false, pressed)),
themeStyles.emojiItem,
]}
Expand Down
6 changes: 1 addition & 5 deletions src/components/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,6 @@ type MenuItemBaseProps = {
/** Should we remove the background color of the menu item */
shouldRemoveBackground?: boolean;

/** Should we remove the hover background color of the menu item */
shouldRemoveHoverBackground?: boolean;

/** Should we use default cursor for disabled content */
shouldUseDefaultCursorWhenDisabled?: boolean;

Expand Down Expand Up @@ -414,7 +411,6 @@ function MenuItem(
shouldEscapeText = undefined,
shouldGreyOutWhenDisabled = true,
shouldRemoveBackground = false,
shouldRemoveHoverBackground = false,
shouldUseDefaultCursorWhenDisabled = false,
shouldShowLoadingSpinnerIcon = false,
isAnonymousAction = false,
Expand Down Expand Up @@ -598,7 +594,7 @@ function MenuItem(
StyleUtils.getButtonBackgroundColorStyle(getButtonState(focused || isHovered, pressed, success, disabled, interactive), true),
...(Array.isArray(wrapperStyle) ? wrapperStyle : [wrapperStyle]),
shouldGreyOutWhenDisabled && disabled && styles.buttonOpacityDisabled,
isHovered && interactive && !focused && !pressed && !shouldRemoveBackground && !shouldRemoveHoverBackground && styles.hoveredComponentBG,
isHovered && interactive && !focused && !pressed && !shouldRemoveBackground && styles.hoveredComponentBG,
] as StyleProp<ViewStyle>
}
disabledStyle={shouldUseDefaultCursorWhenDisabled && [styles.cursorDefault]}
Expand Down
4 changes: 0 additions & 4 deletions src/components/PopoverMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type {ModalProps} from 'react-native-modal';
import useArrowKeyFocusManager from '@hooks/useArrowKeyFocusManager';
import useKeyboardShortcut from '@hooks/useKeyboardShortcut';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useStyleUtils from '@hooks/useStyleUtils';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import useWindowDimensions from '@hooks/useWindowDimensions';
Expand Down Expand Up @@ -168,7 +167,6 @@ function PopoverMenu({
shouldUpdateFocusedIndex = true,
}: PopoverMenuProps) {
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const theme = useTheme();
// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to apply correct popover styles
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
Expand Down Expand Up @@ -265,8 +263,6 @@ function PopoverMenu({
setFocusedIndex(menuIndex);
}}
style={{backgroundColor: item.isSelected ? theme.activeComponentBG : undefined}}
wrapperStyle={StyleUtils.getItemBackgroundColorStyle(!!item.isSelected, focusedIndex === menuIndex, theme.activeComponentBG, theme.hoverComponentBG)}
shouldRemoveHoverBackground={item.isSelected}
titleStyle={StyleSheet.flatten([styles.flex1, item.titleStyle])}
// Spread other props dynamically
{...menuItemProps}
Expand Down
4 changes: 1 addition & 3 deletions src/components/SelectionList/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback';
import PressableWithFeedback from '@components/Pressable/PressableWithFeedback';
import useHover from '@hooks/useHover';
import {useMouseContext} from '@hooks/useMouseContext';
import useStyleUtils from '@hooks/useStyleUtils';
import useSyncFocus from '@hooks/useSyncFocus';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -39,7 +38,6 @@ function BaseListItem<TItem extends ListItem>({
}: BaseListItemProps<TItem>) {
const theme = useTheme();
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const {hovered, bind} = useHover();
const {isMouseDownOnInput, setMouseUp} = useMouseContext();

Expand Down Expand Up @@ -104,7 +102,7 @@ function BaseListItem<TItem extends ListItem>({
tabIndex={item.tabIndex}
wrapperStyle={pressableWrapperStyle}
>
<View style={[wrapperStyle, StyleUtils.getItemBackgroundColorStyle(!!item.isSelected, !!isFocused, theme.activeComponentBG, theme.hoverComponentBG)]}>
<View style={wrapperStyle}>
{typeof children === 'function' ? children(hovered) : children}

{!canSelectMultiple && !!item.isSelected && !rightHandSideComponent && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function TransactionListItem<TItem extends ListItem>({
// Removing background style because they are added to the parent OpacityView via animatedHighlightStyle
styles.bgTransparent,
item.isSelected && styles.activeComponentBG,
isFocused && styles.hoveredComponentBG,
isFocused && styles.sidebarLinkActive,
styles.mh0,
];

Expand Down
18 changes: 3 additions & 15 deletions src/styles/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,19 +1119,6 @@ function getAmountWidth(amount: string): number {
return width;
}

function getItemBackgroundColorStyle(isSelected: boolean, isFocused: boolean, selectedBG: string, focusedBG: string): ViewStyle {
let backgroundColor;
if (isSelected) {
backgroundColor = selectedBG;
} else if (isFocused) {
backgroundColor = focusedBG;
}

return {
backgroundColor,
};
}

const staticStyleUtils = {
positioning,
combineStyles,
Expand Down Expand Up @@ -1206,7 +1193,6 @@ const staticStyleUtils = {
getAmountWidth,
getBorderRadiusStyle,
getHighResolutionInfoWrapperStyle,
getItemBackgroundColorStyle,
};

const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({
Expand All @@ -1225,7 +1211,9 @@ const createStyleUtils = (theme: ThemeColors, styles: ThemeStyles) => ({
getAutoCompleteSuggestionItemStyle: (highlightedEmojiIndex: number, rowHeight: number, isHovered: boolean, currentEmojiIndex: number): ViewStyle[] => {
let backgroundColor;

if (isHovered || currentEmojiIndex === highlightedEmojiIndex) {
if (currentEmojiIndex === highlightedEmojiIndex) {
backgroundColor = theme.activeComponentBG;
} else if (isHovered) {
backgroundColor = theme.hoverComponentBG;
}

Expand Down

0 comments on commit aff5b6a

Please sign in to comment.