Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent scroll on va-number-input from updating value when input is focused #801

Closed
wants to merge 8 commits into from
16 changes: 16 additions & 0 deletions packages/web-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,14 @@ export namespace Components {
* Display last page number when the page count exceeds `maxPageListLength`
*/
"showLastPage"?: boolean;
/**
* Don't show last page when the page count exceeds `maxPageListLength` (but do show the ellipsis). Only relevant if uswds is true.
*/
"unbounded"?: boolean;
/**
* Whether or not the component will use USWDS v3 styling.
*/
"uswds"?: boolean;
}
interface VaPrivacyAgreement {
/**
Expand Down Expand Up @@ -2581,6 +2589,14 @@ declare namespace LocalJSX {
* Display last page number when the page count exceeds `maxPageListLength`
*/
"showLastPage"?: boolean;
/**
* Don't show last page when the page count exceeds `maxPageListLength` (but do show the ellipsis). Only relevant if uswds is true.
*/
"unbounded"?: boolean;
/**
* Whether or not the component will use USWDS v3 styling.
*/
"uswds"?: boolean;
}
interface VaPrivacyAgreement {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import i18next from 'i18next';
/**
* @nativeHandler onInput
* @nativeHandler onBlur
* @nativeHandler onWheel
* @componentName Number input
* @maturityCategory use
* @maturityLevel deployed
Expand Down Expand Up @@ -133,6 +134,12 @@ export class VaNumberInput {
}
};

// prevent input value from changing if user accidentally scrolls while focused on input
private handleWheel = (e: Event) => {
e.preventDefault();
}


connectedCallback() {
i18next.on('languageChanged', () => {
forceUpdate(this.el);
Expand All @@ -158,6 +165,7 @@ export class VaNumberInput {
uswds,
handleBlur,
handleInput,
handleWheel,
width,
messageAriaDescribedby,
} = this;
Expand Down Expand Up @@ -211,6 +219,7 @@ export class VaNumberInput {
required={required || null}
onInput={handleInput}
onBlur={handleBlur}
onWheel={handleWheel}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this more organic solution not work?

from <input type="number"> to <input type="text" inputmode="numeric" pattern="[0-9]*">

/>
{messageAriaDescribedby && (
<span id="input-message" class="sr-only">
Expand Down Expand Up @@ -256,6 +265,7 @@ export class VaNumberInput {
required={required || null}
onInput={handleInput}
onBlur={handleBlur}
onWheel={handleWheel}
/>
{messageAriaDescribedby && (
<span id="input-message" class="sr-only">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
@forward 'settings';
@use 'usa-pagination/src/styles/_usa-pagination.scss';
@use 'usa-icon/src/styles/_usa-icon.scss';

@import '../../mixins/focusable.css';

:host([uswds]) .usa-pagination .usa-current {
background-color: var(--color-primary);
}

:host {
background-color: var(--color-white);
border-top: 1px solid var(--color-gray-lightest);
Expand Down
Loading
Loading