Skip to content

Commit a852ef5

Browse files
authored
Fix error in modal closing behavior (#1475)
* Don't assume modal exists when calling .close() * Update tooltips
1 parent 606e1ee commit a852ef5

File tree

14 files changed

+18
-15
lines changed

14 files changed

+18
-15
lines changed

apps/hyperdrive-trading/src/ui/hyperdrive/longs/CloseLongForm/CloseLongForm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,9 @@ export function CloseLongForm({
125125
asBase: activeWithdrawToken.address === hyperdrive.poolConfig.baseToken,
126126
enabled: previewCloseLongStatus === "success",
127127
onSubmitted: () => {
128-
(document.getElementById(`${long.assetId}`) as HTMLDialogElement).close();
128+
(
129+
document.getElementById(`${long.assetId}`) as HTMLDialogElement
130+
)?.close();
129131
},
130132
onExecuted: () => {
131133
setAmount("");

apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongForm/OpenLongForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export function OpenLongForm({
186186
destination: account,
187187
enabled: openLongPreviewStatus === "success" && hasEnoughAllowance,
188188
onSubmitted: () => {
189-
(document.getElementById("open-long") as HTMLDialogElement).close();
189+
(document.getElementById("open-long") as HTMLDialogElement)?.close();
190190
},
191191
onExecuted: () => {
192192
setAmount("");

apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongForm/OpenLongForm2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export function OpenLongForm2({
183183
destination: account,
184184
enabled: openLongPreviewStatus === "success" && hasEnoughAllowance,
185185
onSubmitted: () => {
186-
(document.getElementById("open-long") as HTMLDialogElement).close();
186+
(document.getElementById("open-long") as HTMLDialogElement)?.close();
187187
},
188188
onExecuted: () => {
189189
setAmount("");

apps/hyperdrive-trading/src/ui/hyperdrive/longs/OpenLongModalButton/OpenLongModalButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function OpenLongModalButton({
2424

2525
function closeModal() {
2626
// eslint-disable-next-line @typescript-eslint/no-explicit-any
27-
(window as any)[modalId].close();
27+
(window as any)[modalId]?.close();
2828
}
2929

3030
if (marketState?.isPaused) {

apps/hyperdrive-trading/src/ui/hyperdrive/lp/AddLiquidityForm/AddLiquidityForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export function AddLiquidityForm({
243243
addLiquidityPreviewStatus === "success",
244244
onSubmitted: () => {
245245
// eslint-disable-next-line @typescript-eslint/no-explicit-any
246-
(window as any)["add-lp"].close();
246+
(window as any)["add-lp"]?.close();
247247
},
248248
onExecuted: () => {
249249
setAmount("");

apps/hyperdrive-trading/src/ui/hyperdrive/lp/AddLiquidityForm/AddLiquidityForm2.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export function AddLiquidityForm2({
241241
addLiquidityPreviewStatus === "success",
242242
onSubmitted: () => {
243243
// eslint-disable-next-line @typescript-eslint/no-explicit-any
244-
(window as any)["add-lp"].close();
244+
(window as any)["add-lp"]?.close();
245245
},
246246
onExecuted: () => {
247247
setAmount("");

apps/hyperdrive-trading/src/ui/hyperdrive/lp/OpenLpSharesCard/OpenLpSharesCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export function OpenLpSharesCard({
227227
className="daisy-btn daisy-btn-circle daisy-btn-ghost daisy-btn-sm absolute right-4 top-4"
228228
onClick={() =>
229229
// eslint-disable-next-line @typescript-eslint/no-explicit-any
230-
(window as any)["withdrawalLpModal"].close()
230+
(window as any)["withdrawalLpModal"]?.close()
231231
}
232232
>
233233
<XMarkIcon className="w-6" title="Close" />

apps/hyperdrive-trading/src/ui/hyperdrive/lp/RemoveLiquidityForm/RemoveLiquidityForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ export function RemoveLiquidityForm({
157157
activeWithdrawToken.address === baseToken.address,
158158
onSubmitted: () => {
159159
// eslint-disable-next-line @typescript-eslint/no-explicit-any
160-
(window as any)["withdrawalLpModal"].close();
160+
(window as any)["withdrawalLpModal"]?.close();
161161
},
162162
onExecuted: () => {
163163
setAmount("");

apps/hyperdrive-trading/src/ui/hyperdrive/shorts/CloseShortForm/CloseShortForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function CloseShortForm({
110110
hyperdrive.withdrawOptions.isBaseTokenWithdrawalEnabled &&
111111
activeWithdrawToken.address === hyperdrive.poolConfig.baseToken,
112112
onSubmitted: (hash) => {
113-
(window as any)[`${short.assetId}`].close();
113+
(window as any)[`${short.assetId}`]?.close();
114114
},
115115
onExecuted: (hash) => {
116116
setAmount("");

apps/hyperdrive-trading/src/ui/hyperdrive/shorts/CloseShortModalButton/CloseShortModalButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function CloseShortModalButton({
4444
const maturityMilliseconds = Number(short.maturity * 1000n);
4545
const isMature = Date.now() > maturityMilliseconds;
4646
function closeModal() {
47-
(window as any)[modalId].close();
47+
(window as any)[modalId]?.close();
4848
}
4949

5050
return (

0 commit comments

Comments
 (0)