-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwallet-width-fix.js
More file actions
63 lines (54 loc) · 2.39 KB
/
wallet-width-fix.js
File metadata and controls
63 lines (54 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Wallet Width Fix - Force wallet names to have adequate width
// This fixes the width constraint issue by setting minimum width with !important
function forceWalletWidth() {
// Find all wallet chip text elements
const walletTexts = document.querySelectorAll('.selected-wallet-chip .chip-text');
walletTexts.forEach(textElement => {
// Force minimum width to display at least 6 characters
textElement.style.setProperty('min-width', '50px', 'important');
textElement.style.setProperty('width', 'auto', 'important');
textElement.style.setProperty('max-width', '200px', 'important');
textElement.style.setProperty('flex-shrink', '0', 'important');
textElement.style.setProperty('display', 'inline-block', 'important');
// Also force the parent chip container
const chipContainer = textElement.closest('.selected-wallet-chip');
if (chipContainer) {
chipContainer.style.setProperty('min-width', '60px', 'important');
chipContainer.style.setProperty('width', 'auto', 'important');
chipContainer.style.setProperty('max-width', '220px', 'important');
chipContainer.style.setProperty('flex-shrink', '0', 'important');
}
});
}
// Run the fix whenever wallet display is updated
function observeWalletWidth() {
const headerWalletsDisplay = document.getElementById('header-wallets-display');
if (headerWalletsDisplay) {
// Create a mutation observer to watch for changes
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'childList') {
// Delay slightly to ensure DOM is updated
setTimeout(forceWalletWidth, 10);
}
});
});
// Start observing
observer.observe(headerWalletsDisplay, {
childList: true,
subtree: true
});
// Run initial fix
forceWalletWidth();
}
}
// Initialize when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', observeWalletWidth);
} else {
observeWalletWidth();
}
// Also run periodically as a backup
setInterval(forceWalletWidth, 1000);
// Make it globally accessible for manual testing
window.forceWalletWidth = forceWalletWidth;