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: SafeNonceSelector dropdown #1771

Merged
merged 1 commit into from
Sep 22, 2023
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
24 changes: 13 additions & 11 deletions src/ui/views/Approval/components/TxComponents/SafeNonceSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useAccount } from '@/ui/store-hooks';
import { useWallet } from '@/ui/utils';
import { findChainByID } from '@/utils/chain';
import { BasicSafeInfo } from '@rabby-wallet/gnosis-sdk';
import { SafeTransactionItem } from '@rabby-wallet/gnosis-sdk/dist/api';
import { useRequest } from 'ahooks';
import { Form, Input, Skeleton, Spin } from 'antd';
import clsx from 'clsx';
import { INTERNAL_REQUEST_ORIGIN } from 'consts';
import { maxBy, sortBy, uniqBy } from 'lodash';
import React, {
MouseEventHandler,
Expand All @@ -19,11 +19,10 @@ import { Trans, useTranslation } from 'react-i18next';
import styled from 'styled-components';
import IconChecked from 'ui/assets/safe-nonce-select/checked.svg';
import IconDown from 'ui/assets/safe-nonce-select/down.svg';
import IconUnchecked from 'ui/assets/safe-nonce-select/unchecked.svg';
import IconFind from 'ui/assets/safe-nonce-select/find.svg';
import IconUnchecked from 'ui/assets/safe-nonce-select/unchecked.svg';
import { intToHex } from 'ui/utils/number';
import { findChainByID } from '@/utils/chain';
import { getActionTypeText, getActionTypeTextByType } from '../Actions/utils';
import { getActionTypeTextByType } from '../Actions/utils';

const Wrapper = styled.div`
border-radius: 6px;
Expand Down Expand Up @@ -199,18 +198,21 @@ export const SafeNonceSelector = ({
} else {
onChange?.(intToHex(v));
}
setIsShowOptionList(false);
};

const optionListRef = useRef<HTMLDivElement>(null);

useEffect(() => {
const parent = document.querySelector('.approval-tx');
if (optionListRef.current && parent) {
const shouldScroll =
optionListRef.current.getBoundingClientRect().top + 52 >
parent.getBoundingClientRect().height;
if (shouldScroll) {
parent.scrollTo(0, parent.scrollTop + 128);
if (isShowOptionList) {
const parent = document.querySelector('.approval-tx');
if (optionListRef.current && parent) {
const shouldScroll =
optionListRef.current.getBoundingClientRect().top + 52 >
parent.getBoundingClientRect().height;
if (shouldScroll) {
parent.scrollTo(0, parent.scrollTop + 128);
}
}
}
}, [isShowOptionList]);
Expand Down