File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed
src/lib/form/bignumber-field Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -513,9 +513,35 @@ export function useBigNumberField(props: BigNumberFieldProps) {
513513 e . preventDefault ( ) ;
514514 } ;
515515
516+ // prevent page scrolling when scrolling inside input
517+ useEffect ( ( ) => {
518+ const input = document . getElementById ( "BigNumberField" ) ;
519+
520+ const preventScroll = ( e : globalThis . WheelEvent ) => {
521+ if ( input && document . activeElement === input ) {
522+ // Stop page scroll
523+ e . preventDefault ( ) ;
524+ }
525+ } ;
526+
527+ input ?. addEventListener ( "wheel" , preventScroll , { passive : false } ) ;
528+
529+ return ( ) => {
530+ input ?. removeEventListener ( "wheel" , preventScroll ) ;
531+ } ;
532+ } , [ ] ) ;
533+
516534 // Handle wheel events
517535 const handleWheel = ( e : WheelEvent < HTMLInputElement > ) => {
518- if ( isDisabled || isReadOnly || isWheelDisabled ) return ;
536+ const input = document . getElementById ( "BigNumberField" ) ;
537+ if (
538+ isDisabled ||
539+ isReadOnly ||
540+ isWheelDisabled ||
541+ // only scroll if input is in focus
542+ document . activeElement !== input
543+ )
544+ return ;
519545
520546 // If on a trackpad, users can scroll in both X and Y at once, check the magnitude of the change
521547 // if it's mostly in the X direction, then just return, the user probably doesn't mean to inc/dec
You can’t perform that action at this time.
0 commit comments