-
Notifications
You must be signed in to change notification settings - Fork 51
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
fix(input): fix set selection range #1488
Conversation
🦋 Changeset detectedLatest commit: 8e8e189 The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Pull Request Test Coverage Report for Build 12278796593Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Собрана новая демка. |
@@ -288,7 +290,7 @@ export const BaseInput = React.forwardRef<HTMLInputElement, BaseInputProps>( | |||
if (restProps.autoFocus) { | |||
const input = inputRef.current; | |||
|
|||
if (input) { | |||
if (input && inputTypesForSelectionRange.includes(input.type)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useLayoutEffect_SAFE_FOR_SSR(() => {
const input = inputRef.current;
if (
!restProps.autoFocus ||
!input ||
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
!inputTypesForSelectionRange.includes(input.type)
) {
return;
}
// https://github.com/facebook/react/issues/14125
input.setSelectionRange(input.value.length, input.value.length);
}, []);
может поправим сразу?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
спасибо ) подправил
Собрана новая демка. |
* fix(input): fix set selection range * feat(input): refactor use effect --------- Co-authored-by: Aleksandr Dyuzhikov <adyuzhikov@alfabank.ru>
Опишите проблему
При поднятии версии пакета начали падать тесты с ошибкой InvalidStateError
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/setSelectionRange
метод поддерживается только на определенных типах инпута