Skip to content

Commit f444fc4

Browse files
committed
Fix tooltip
1 parent e92ff48 commit f444fc4

4 files changed

Lines changed: 27 additions & 7 deletions

File tree

packages/app/components/common/Tooltip.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function Tooltip({
4242
{...contentProps}
4343
className={twMerge(
4444
contentProps?.className,
45-
'tooltip-animated z-50 min-w-0 max-w-[300px] bg-gray-8 overflow-hidden rounded-[5px] px-2 py-1 text-sm leading-5 border border-[#777] whitespace-normal break-words',
45+
'tooltip-animated z-[1102] min-w-0 max-w-[300px] bg-gray-8 overflow-hidden rounded-[5px] px-2 py-1 text-sm leading-5 border border-[#777] whitespace-normal break-words',
4646
)}
4747
>
4848
{content}

packages/app/src/app.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ input:focus-visible {
168168
--tooltip-translate-y: 0px;
169169
}
170170

171-
.tooltip-animated[data-state='delayed-open'] {
171+
.tooltip-animated[data-state='delayed-open'],
172+
.tooltip-animated[data-state='instant-open'] {
172173
animation: tooltipIn 120ms ease-out;
173174
}
174175

packages/arb-token-bridge-ui/src/util/networks.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ export type ChainWithRpcUrl = ArbitrumNetwork & {
101101
nativeTokenData?: Erc20Data;
102102
};
103103

104+
function getAvailableLocalStorage(): Pick<Storage, 'getItem' | 'setItem'> | null {
105+
if (
106+
typeof localStorage === 'undefined' ||
107+
typeof localStorage.getItem !== 'function' ||
108+
typeof localStorage.setItem !== 'function'
109+
) {
110+
return null;
111+
}
112+
113+
return localStorage;
114+
}
115+
104116
export function getBlockNumberReferenceChainIdByChainId({ chainId }: { chainId: number }): number {
105117
// the chain provided is an L1 chain or Base chain, so we can return early
106118
if (isBlockNumberReferenceNetwork({ chainId })) {
@@ -134,9 +146,10 @@ export function getBlockNumberReferenceChainIdByChainId({ chainId }: { chainId:
134146
}
135147

136148
export function getCustomChainsFromLocalStorage(): ChainWithRpcUrl[] {
137-
if (typeof localStorage === 'undefined') return []; // required so that it does not fail test-runners
149+
const storage = getAvailableLocalStorage();
150+
if (!storage) return []; // required so that it does not fail outside browser runtime
138151

139-
const customChainsFromLocalStorage = localStorage.getItem(customChainLocalStorageKey);
152+
const customChainsFromLocalStorage = storage.getItem(customChainLocalStorageKey);
140153

141154
if (!customChainsFromLocalStorage) {
142155
return [];
@@ -171,6 +184,9 @@ export function getCustomChainFromLocalStorageById(chainId: ChainId) {
171184
}
172185

173186
export function saveCustomChainToLocalStorage(newCustomChain: ChainWithRpcUrl) {
187+
const storage = getAvailableLocalStorage();
188+
if (!storage) return;
189+
174190
const customChains = getCustomChainsFromLocalStorage();
175191

176192
if (customChains.findIndex((chain) => chain.chainId === newCustomChain.chainId) > -1) {
@@ -180,15 +196,18 @@ export function saveCustomChainToLocalStorage(newCustomChain: ChainWithRpcUrl) {
180196

181197
const newCustomChains = [...getCustomChainsFromLocalStorage(), newCustomChain];
182198

183-
localStorage.setItem(customChainLocalStorageKey, JSON.stringify(newCustomChains));
199+
storage.setItem(customChainLocalStorageKey, JSON.stringify(newCustomChains));
184200
}
185201

186202
export function removeCustomChainFromLocalStorage(chainId: number) {
203+
const storage = getAvailableLocalStorage();
204+
if (!storage) return;
205+
187206
const newCustomChains = getCustomChainsFromLocalStorage().filter(
188207
(chain) => chain.chainId !== chainId,
189208
);
190209

191-
localStorage.setItem(customChainLocalStorageKey, JSON.stringify(newCustomChains));
210+
storage.setItem(customChainLocalStorageKey, JSON.stringify(newCustomChains));
192211
}
193212

194213
export const supportedCustomOrbitParentChains = [

packages/arb-token-bridge-ui/src/util/walletConnectUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export function onDisconnectHandler() {
33
return;
44
}
55

6-
if (typeof localStorage === 'undefined') {
6+
if (typeof localStorage === 'undefined' || typeof localStorage.getItem !== 'function') {
77
return;
88
}
99

0 commit comments

Comments
 (0)