Skip to content

Commit

Permalink
Scroll to actions after hitting borrow button
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarvu committed Dec 16, 2024
1 parent ee4bdc7 commit 99b948f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/app/src/features/easy-borrow/EasyBorrowContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function EasyBorrowContainer() {
borrowDetails,
guestMode,
openSandboxModal,
healthFactorPanelRef,
actionsPanelRef,
riskAcknowledgement,
actionsContext,
} = useEasyBorrow()
Expand Down Expand Up @@ -53,7 +53,7 @@ function EasyBorrowContainer() {
guestMode={guestMode}
openConnectModal={openConnectModal}
openSandboxModal={openSandboxModal}
healthFactorPanelRef={healthFactorPanelRef}
actionsPanelRef={actionsPanelRef}
riskAcknowledgement={riskAcknowledgement}
actionsContext={actionsContext}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export interface EasyBorrowPanelProps {
guestMode: boolean
openConnectModal: () => void
openSandboxModal: () => void
healthFactorPanelRef: React.RefObject<HTMLDivElement>
actionsPanelRef: React.RefObject<HTMLDivElement>
actionsContext: InjectedActionsContext
}

Expand Down Expand Up @@ -75,7 +75,7 @@ export function EasyBorrowPanel(props: EasyBorrowPanelProps) {
)}
</Panel>
)}
<Panel>
<Panel ref={props.actionsPanelRef}>
<ActionsContainer
objectives={objectives}
context={actionsContext}
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/features/easy-borrow/logic/useEasyBorrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface UseEasyBorrowResults {
borrowDetails: BorrowDetails
guestMode: boolean
openSandboxModal: () => void
healthFactorPanelRef: React.RefObject<HTMLDivElement>
actionsPanelRef: React.RefObject<HTMLDivElement>
actionsContext: InjectedActionsContext
}

Expand All @@ -85,7 +85,7 @@ export function useEasyBorrow(): UseEasyBorrowResults {
const upgradeOptions = useUpgradeOptions({ chainId, daiSymbol })

const [pageStatus, setPageStatus] = useState<PageState>('form')
const healthFactorPanelRef = useRef<HTMLDivElement>(null)
const actionsPanelRef = useRef<HTMLDivElement>(null)

const userPositions = imputeNativeAsset(marketInfo, nativeAssetInfo)
const alreadyDeposited = useConditionalFreeze(
Expand Down Expand Up @@ -199,7 +199,7 @@ export function useEasyBorrow(): UseEasyBorrowResults {
)
useEffect(() => {
if (pageStatus === 'confirmation') {
healthFactorPanelRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' })
actionsPanelRef.current?.scrollIntoView({ behavior: 'smooth', block: 'start' })
}
}, [pageStatus])

Expand Down Expand Up @@ -243,7 +243,7 @@ export function useEasyBorrow(): UseEasyBorrowResults {
borrowDetails,
guestMode,
openSandboxModal,
healthFactorPanelRef,
actionsPanelRef,
riskAcknowledgement,
actionsContext: {
marketInfo,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function EasyBorrowViewStory(props: EasyBorrowViewStoryProps) {
guestMode={guestMode}
openConnectModal={openConnectModal}
openSandboxModal={openSandboxModal}
healthFactorPanelRef={healthFactorPanelRef}
actionsPanelRef={healthFactorPanelRef}
riskAcknowledgement={riskAcknowledgement}
actionsContext={{ marketInfo: mockMarketInfo }}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface EasyBorrowViewProps {
guestMode: boolean
openConnectModal: () => void
openSandboxModal: () => void
healthFactorPanelRef: React.RefObject<HTMLDivElement>
actionsPanelRef: React.RefObject<HTMLDivElement>
actionsContext: InjectedActionsContext
}

Expand Down

0 comments on commit 99b948f

Please sign in to comment.