Skip to content

Commit

Permalink
fix: Reset value onBlur and attempt disable auto
Browse files Browse the repository at this point in the history
  • Loading branch information
antonjoel82 committed Feb 27, 2024
1 parent b6821fb commit b633007
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libs/design-system/src/pagination/GoToPageInput.tsx
Expand Up @@ -67,6 +67,7 @@ export const GoToPageInput: React.FC<IGoToPageInputProps> = forwardRef<HTMLInput
({ label, firstPageNumber = FIRST_PAGE_NUMBER, ...inputProps }, forwardedRef) => {
const { onPageChange, totalPageCount } = useContext(PaginationContext);
const [hasError, setHasError] = useState<boolean>(false);
const [goToValue, setGoToValue] = useState<number | undefined>(undefined);

const validateValue = (val: number | string) => {
const numVal = +val;
Expand Down Expand Up @@ -97,7 +98,7 @@ export const GoToPageInput: React.FC<IGoToPageInputProps> = forwardRef<HTMLInput
return;
}
onPageChange(+val);
internalRef.current.value = undefined;
setGoToValue(undefined);
setHasError(false);
};

Expand All @@ -119,6 +120,8 @@ export const GoToPageInput: React.FC<IGoToPageInputProps> = forwardRef<HTMLInput
>
<NumberInput
onKeyDown={handleKeyPress}
value={goToValue}
onChange={setGoToValue}
id={'goToPage'}
ref={internalRef}
onBlur={handleBlurEvent}
Expand All @@ -127,6 +130,9 @@ export const GoToPageInput: React.FC<IGoToPageInputProps> = forwardRef<HTMLInput
maxLength={`${totalPageCount}`.length}
hideControls
noClampOnBlur
autoCorrect={'none'}
aria-autocomplete={'none'}
autoComplete={'none'}
disabled={totalPageCount === 1}
{...inputProps}
/>
Expand Down

0 comments on commit b633007

Please sign in to comment.