Skip to content

Commit

Permalink
fix: SafeNonceSelector dropdown (#1771)
Browse files Browse the repository at this point in the history
  • Loading branch information
cs1707 authored Sep 22, 2023
1 parent 0d2962d commit ec55244
Showing 1 changed file with 13 additions and 11 deletions.
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

0 comments on commit ec55244

Please sign in to comment.