Skip to content

fix(widget): refit amount text when its container resizes - #890

Open
BiscuitCoder wants to merge 1 commit into
lifinance:mainfrom
BiscuitCoder:codex/resize-amount-text
Open

BiscuitCoder wants to merge 1 commit into
lifinance:mainfrom
BiscuitCoder:codex/resize-amount-text

Conversation

@BiscuitCoder

Copy link
Copy Markdown

Which Linear task is linked to this PR?

No Linear task; external bug-fix contribution.

Why was it implemented this way?

The send and receive amount cards fit their text only when the displayed value changes. If an embedding container becomes narrower while the amount stays the same, the old font size remains: the input clips its value and the receive text can overflow into the token selector. Growing the container again also leaves previously reduced text unnecessarily small.

Observe each amount element with ResizeObserver and reuse the existing fitInputText calculation. Keep the initial/value-change fit and disconnect each observer when the effect is replaced or the card unmounts. The receive effect also depends on showSkeleton, so it attaches when a loading placeholder is replaced by an amount with the same display value.

No layout, font limits, public API or dependencies change. Includes a Widget patch changeset.

Validation:

  • Five component regression cases cover shrinking and growing with unchanged values, value changes, observer cleanup, and loading-placeholder replacement.
  • All 280 Widget tests passed across 21 files.
  • Widget production build, type check, changed-file Biome check and Changesets status passed.
  • Chromium comparison used the actual source components and MUI styles in an isolated resizable host with fixed token/quote data. The same check reproduced the overflow on the upstream components and passed with the fix, with no browser errors.

Visual showcase (Screenshots or Videos)

Keep 123456789012 unchanged and resize the host from 480px to 300px, then back. In the isolated card fixture, the amount element's available width changes from 342px to 162px:

Upstream at narrow width With fix at narrow width With fix after growing
Send font size 30px 22px 30px
Receive font size 30px 23px 30px
Amount scroll width / available width 204px / 162px 162px / 162px 342px / 342px

The displayed amount stays unchanged throughout.

Checklist before requesting a review

  • I have performed a self-review and testing of my code.
  • This pull request is focused and addresses a single problem.
  • If this PR modifies the Widget API or adds new features that require documentation, I have updated the documentation in the public-docs repository. (Not applicable: internal bug fix.)

@BiscuitCoder
BiscuitCoder force-pushed the codex/resize-amount-text branch from ab596ce to e78a0de Compare September 29, 2026 15:16
@changeset-bot

changeset-bot Bot commented Sep 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e78a0de

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@lifi/widget Patch
@lifi/widget-checkout Patch
nft-checkout Patch
tanstack-router-example Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

This branch has not been deployed

No deployments
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.

1 participant