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: dropdown menu misalign on search page #47987

Merged
merged 5 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion src/components/ButtonWithDropdownMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ function ButtonWithDropdownMenu<IValueType>({
enterKeyEventListenerPriority = 0,
wrapperStyle,
useKeyboardShortcuts = false,
shouldUseStyleUtilityForAnchorPosition = false,
defaultSelectedIndex = 0,
shouldShowSelectedItemCheck = false,
}: ButtonWithDropdownMenuProps<IValueType>) {
Expand Down Expand Up @@ -175,7 +176,7 @@ function ButtonWithDropdownMenu<IValueType>({
}}
onModalShow={onOptionsMenuShow}
onItemSelected={() => setIsMenuVisible(false)}
anchorPosition={popoverAnchorPosition}
anchorPosition={shouldUseStyleUtilityForAnchorPosition ? styles.popoverButtonDropdownMenuOffset(windowWidth) : popoverAnchorPosition}
shouldShowSelectedItemCheck={shouldShowSelectedItemCheck}
anchorRef={nullCheckRef(dropdownAnchor)}
withoutOverlay
Expand Down
3 changes: 3 additions & 0 deletions src/components/ButtonWithDropdownMenu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ type ButtonWithDropdownMenuProps<TValueType> = {
/** Whether to use keyboard shortcuts for confirmation or not */
useKeyboardShortcuts?: boolean;

/** Determines if a style utility function should be used for calculating the PopoverMenu anchor position. */
shouldUseStyleUtilityForAnchorPosition?: boolean;

/** Decides which index in menuItems should be selected */
defaultSelectedIndex?: number;

Expand Down
1 change: 1 addition & 0 deletions src/components/Search/SearchPageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ function SearchPageHeader({queryJSON, hash, onSelectDeleteOption, setOfflineModa
customText={translate('workspace.common.selected', {selectedNumber: selectedTransactionsKeys.length})}
options={headerButtonsOptions}
isSplitButton={false}
shouldUseStyleUtilityForAnchorPosition
daledah marked this conversation as resolved.
Show resolved Hide resolved
/>
) : (
<Button
Expand Down
6 changes: 6 additions & 0 deletions src/styles/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3646,6 +3646,12 @@ const styles = (theme: ThemeColors) =>
horizontal: windowWidth - 355,
} satisfies AnchorPosition),

popoverButtonDropdownMenuOffset: (windowWidth: number) =>
({
...getPopOverVerticalOffset(70),
horizontal: windowWidth - 20,
daledah marked this conversation as resolved.
Show resolved Hide resolved
} satisfies AnchorPosition),

iPhoneXSafeArea: {
backgroundColor: theme.inverse,
flex: 1,
Expand Down
Loading