()
| 240 | |
| 241 | // Calculate dynamic width based on expected value range |
| 242 | const calculateInputWidth = () => { |
| 243 | const minDigits = String(Math.floor(element.min || 0)).length; |
| 244 | const maxDigits = String(Math.floor(element.max || 0)).length; |
| 245 | const valueDigits = String(Math.floor(element.value || 0)).length; |
| 246 | const maxLength = Math.max(minDigits, maxDigits, valueDigits, 5); // Minimum 5 digits |
| 247 | // ~8px per character + 20px for padding/controls |
| 248 | return `${maxLength * 8 + 20}px`; |
| 249 | }; |
| 250 | |
| 251 | numberInput.style.width = calculateInputWidth(); |
| 252 | numberInput.style.minWidth = '70px'; // Ensure minimum usable width |
no test coverage detected