Skip to content

feat(web/PositionPanel): handle missing position gracefully with deposit CTA (#560) - #629

Merged
Mimah97 merged 1 commit into
Vatix-Protocol:devfrom
davismas23:feat/560-position-panel-empty-state
Jul 28, 2026
Merged

feat(web/PositionPanel): handle missing position gracefully with deposit CTA (#560)#629
Mimah97 merged 1 commit into
Vatix-Protocol:devfrom
davismas23:feat/560-position-panel-empty-state

Conversation

@davismas23

Copy link
Copy Markdown
Contributor

Summary

Closes #560

Upgrades the PositionPanel empty state from a plain-text message to a purposeful, accessible block that guides users toward opening a position.

Problem

When the contract's get_position returns null (the user has no recorded position in the market), the panel rendered:

You have no open position in this market yet.
Deposit funds above to get started.

This satisfied "no crash" but failed the acceptance criterion "CTA to deposit when empty" — there was no button or interactive element, and the deposit form was potentially off-screen.

Changes

apps/web/components/PositionPanel.tsx

Empty state — replaced the two-line text block with a centred card:

  • Chart-bar icon (aria-hidden) — visual signal that no data is present
  • No open position heading
  • One-line explanation: You don't have an active position in this market yet.
  • Deposit to get started primary button — scrolls the DepositForm into view via scrollIntoView({ behavior: 'smooth', block: 'center' }) and programmatically focuses the amount input

depositFormRef (new) — a useRef<HTMLDivElement> attached to a wrapper <div> around <DepositForm>, giving the CTA a stable DOM target to scroll to.

handleDepositCTA — small helper that reads depositFormRef.current, scrolls, and focuses the first input[type='number'] inside the form.

JSDoc — updated the component docstring to document the empty-state / CTA behaviour.

Import — added useRef to the React import (was unused before).

No-crash guarantee

The !position branch in the conditional render tree was already correct — all null/absent positions reach the empty-state path without throwing. This PR only changes what is rendered in that branch, not the guard logic.

} : !position ? (
  // NEW: accessible empty state with deposit CTA
  <div className="flex flex-col items-center …">
    <svg aria-hidden="true"  />
    <p>No open position</p>
    <p>You don't have an active position …</p>
    <button onClick={handleDepositCTA}>Deposit to get started</button>
  </div>
) : (
  // existing position grid unchanged

Acceptance criteria

  • No uncaught render error when position is null/absent
  • CTA to deposit when empty (scrolls + focuses DepositForm)

Notes

…sit CTA (Vatix-Protocol#560)

The panel already caught null positions and showed a text message, but
had no actionable call-to-action, which left users with no obvious next
step when the chain returned no position for their address.

Changes
-------
• Empty-state block replaced with a centred card that includes:
  - A chart-bar icon (accessible, aria-hidden) to visually signal 'no data'
  - 'No open position' heading and a one-line explanation
  - 'Deposit to get started' primary button that scrolls the DepositForm
    into view and focuses the amount input — no page navigation required
• Added a depositFormRef (useRef<HTMLDivElement>) attached to a wrapper
  div around <DepositForm> so the CTA can scroll to and focus it
• Added handleDepositCTA helper that calls scrollIntoView (smooth) then
  programmatically focuses the first number input inside the form
• Updated component-level JSDoc to document the empty-state / CTA
  behaviour
• Added useRef to the React import

No-crash guarantee
------------------
All null/undefined positions continue to be handled in the existing
conditional render tree (!position branch); the new empty state simply
replaces the previous plain-text copy with a styled, accessible block.
There is no path that can throw an uncaught render error from a missing
position.

Acceptance criteria
-------------------
✓ No uncaught render error when position is null/absent
✓ CTA to deposit when empty (scrolls to DepositForm + focuses input)

Closes Vatix-Protocol#560
@Mimah97
Mimah97 merged commit e830eb7 into Vatix-Protocol:dev Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Position panel handles missing position gracefully

2 participants