File tree Expand file tree Collapse file tree 3 files changed +62
-50
lines changed
packages/thirdweb/src/react/web/ui
ConnectWallet/screens/Buy Expand file tree Collapse file tree 3 files changed +62
-50
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " thirdweb " : patch
3
+ ---
4
+
5
+ fix losing state when looking at transactions during pay
Original file line number Diff line number Diff line change @@ -498,20 +498,6 @@ function BuyScreenContent(props: BuyScreenContentProps) {
498
498
) }
499
499
500
500
< Container px = "lg" flex = "column" gap = "sm" >
501
- { account && (
502
- < Button
503
- variant = "outline"
504
- fullWidth
505
- style = { {
506
- padding : spacing . xs ,
507
- fontSize : fontSize . sm ,
508
- } }
509
- onClick = { props . onViewPendingTx }
510
- >
511
- View all transactions
512
- </ Button >
513
- ) }
514
-
515
501
{ ! isExpanded && (
516
502
< >
517
503
{ ! account && props . connectButton ? (
@@ -528,6 +514,20 @@ function BuyScreenContent(props: BuyScreenContentProps) {
528
514
) }
529
515
</ >
530
516
) }
517
+
518
+ { account && (
519
+ < Button
520
+ variant = "outline"
521
+ fullWidth
522
+ style = { {
523
+ padding : spacing . xs ,
524
+ fontSize : fontSize . sm ,
525
+ } }
526
+ onClick = { props . onViewPendingTx }
527
+ >
528
+ View all transactions
529
+ </ Button >
530
+ ) }
531
531
</ Container >
532
532
533
533
< Spacer y = "lg" />
Original file line number Diff line number Diff line change
1
+ "use client" ;
2
+
1
3
import { useState } from "react" ;
2
4
import type { Chain } from "../../../chains/types.js" ;
3
5
import type { ThirdwebClient } from "../../../client/client.js" ;
@@ -165,47 +167,52 @@ export function PayEmbed(props: PayEmbedProps) {
165
167
< Spinner size = "xl" color = "secondaryText" />
166
168
</ div >
167
169
) ;
168
- } else if ( screen === "tx-history" ) {
169
- content = (
170
- < BuyTxHistory
171
- client = { props . client }
172
- onBack = { ( ) => {
173
- setScreen ( "buy" ) ;
174
- } }
175
- onDone = { ( ) => {
176
- // noop
177
- } }
178
- isBuyForTx = { false }
179
- isEmbed = { true }
180
- />
181
- ) ;
182
170
} else {
171
+ // show and hide screens with CSS to not lose state when switching between them
183
172
content = (
184
- < BuyScreen
185
- isEmbed = { true }
186
- supportedTokens = { props . supportedTokens }
187
- theme = { props . theme || "dark" }
188
- client = { props . client }
189
- connectLocale = { localeQuery . data }
190
- onViewPendingTx = { ( ) => {
191
- setScreen ( "tx-history" ) ;
192
- } }
193
- payOptions = { props . payOptions || { } }
194
- onDone = { ( ) => {
195
- // noop
196
- } }
197
- connectButton = {
198
- < ConnectButton
199
- { ...props . connectOptions }
173
+ < >
174
+ < div style = { { display : screen === "tx-history" ? "none" : "inherit" } } >
175
+ < BuyScreen
176
+ isEmbed = { true }
177
+ supportedTokens = { props . supportedTokens }
178
+ theme = { props . theme || "dark" }
179
+ client = { props . client }
180
+ connectLocale = { localeQuery . data }
181
+ onViewPendingTx = { ( ) => {
182
+ setScreen ( "tx-history" ) ;
183
+ } }
184
+ payOptions = { props . payOptions || { } }
185
+ onDone = { ( ) => {
186
+ // noop
187
+ } }
188
+ connectButton = {
189
+ < ConnectButton
190
+ { ...props . connectOptions }
191
+ client = { props . client }
192
+ connectButton = { {
193
+ style : {
194
+ width : "100%" ,
195
+ } ,
196
+ } }
197
+ />
198
+ }
199
+ />
200
+ </ div >
201
+ { /* this does not need to persist so we can just show-hide it with JS */ }
202
+ { screen === "tx-history" && (
203
+ < BuyTxHistory
200
204
client = { props . client }
201
- connectButton = { {
202
- style : {
203
- width : "100%" ,
204
- } ,
205
+ onBack = { ( ) => {
206
+ setScreen ( "buy" ) ;
207
+ } }
208
+ onDone = { ( ) => {
209
+ // noop
205
210
} }
211
+ isBuyForTx = { false }
212
+ isEmbed = { true }
206
213
/>
207
- }
208
- />
214
+ ) }
215
+ < />
209
216
) ;
210
217
}
211
218
You can’t perform that action at this time.
0 commit comments