Skip to content

Commit

Permalink
feat(frontend): ux improvements to liquidity dialog component (#2839)
Browse files Browse the repository at this point in the history
* fixed(frontend) asset page now retains page scroll position.

* feat(frontend) added autofocus to liquidity dialog input

* feat(fronted) made eslint happy
  • Loading branch information
Emanuel-Palestino authored Aug 5, 2024
1 parent c61e03e commit b0d282b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion packages/frontend/app/components/LiquidityDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Dialog } from '@headlessui/react'
import { Form } from '@remix-run/react'
import type { ChangeEvent } from 'react'
import { useState } from 'react'
import { useEffect, useRef, useState } from 'react'
import { XIcon } from '~/components/icons'
import { Button, Input } from '~/components/ui'

Expand Down Expand Up @@ -42,6 +42,13 @@ export const LiquidityDialog = ({
setActualAmount(integerScaledInput)
}

const inputRef = useRef<HTMLInputElement>(null)
useEffect(() => {
if (inputRef.current) {
inputRef.current.focus()
}
}, [])

return (
<Dialog as='div' className='relative z-10' onClose={onClose} open={true}>
<div className='fixed inset-0 bg-tealish/30 bg-opacity-75 transition-opacity' />
Expand All @@ -67,6 +74,7 @@ export const LiquidityDialog = ({
</Dialog.Title>
<div className='mt-2'>
<Input
ref={inputRef}
required
type='number'
name='displayAmount'
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/app/routes/assets.$assetId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,15 @@ export default function ViewAssetPage() {
<div className='flex space-x-4'>
<Button
aria-label='deposit asset liquidity page'
preventScrollReset
type='button'
to={`/assets/${asset.id}/deposit-liquidity`}
>
Deposit liquidity
</Button>
<Button
aria-label='withdraw asset liquidity page'
preventScrollReset
type='button'
to={`/assets/${asset.id}/withdraw-liquidity`}
>
Expand Down

0 comments on commit b0d282b

Please sign in to comment.