-
Notifications
You must be signed in to change notification settings - Fork 187
fix(CustomSelect): fix onInputChange callback when reset input value #8636
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
Open
EldarMuhamethanov
wants to merge
2
commits into
master
Choose a base branch
from
e.muhamethanov/8633/custom-select-on-input-change-clear
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix(CustomSelect): fix onInputChange callback when reset input value #8636
EldarMuhamethanov
wants to merge
2
commits into
master
from
e.muhamethanov/8633/custom-select-on-input-change-clear
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size-limit report 📦
|
e2e tests |
👀 Docs deployed
📦 Package ✅yarn add @vkontakte/vkui@https://vkui-screenshot.hb.bizmrg.com/pull/8636/880b9b27f77ed52e8559c887be0851bba6be7839/pkg/@vkontakte/vkui/_pkg.tgz Commit 880b9b2 |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8636 +/- ##
==========================================
- Coverage 95.89% 95.89% -0.01%
==========================================
Files 416 416
Lines 11935 11948 +13
Branches 3949 3951 +2
==========================================
+ Hits 11445 11457 +12
- Misses 490 491 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
onInputChange
при закрытииCustomSelect
#8633Описание
В компоненте
CustomSelect
событиеonInputChange
корректно уведомляет об изменениях значения поискового поля ввода (input
) при взаимодействии пользователя. Однако при закрытии селекта методclose
принудительно сбрасывает значениеinput
(черезsetInputValue('')
), но событиеonInputChange
при этом не вызывается. Это создает неопределенность: значение поля ввода изменилось, но подписчикиonInputChange
не получают уведомления.Значение поля ввода сбрасывается в методе
close
(черезsetInputValue('')
), но событиеonInputChange
не вызывается, что нарушает ожидания разработчика, использующего это событие для отслеживания изменений.Изменения
onInputChange
c переданным событиемonChange
наonInput
по причине того, что в ReactonChange
работает не также как в нативном js - он работает точно также как иonInput
, но его нельзя стригерить черезdispatchEvent
, а input событие можно. По логике ничего сломаться не должноUPD
Вскрылся баг в
CalendarTime
: там использовался пропonInputChange
, в котором мутировалось значение input и выбиралось соответствующее число. И получалось, что при вводе числа, а затем при его выборе, сначала число устанавливалось корректно, а потом из-за того, что значение в инпуте сбрасывалось, то и число тоже сбрасывалось.Придумал следующее решение: в
onChangeInput
добавил вторым параметромreason
- причина изменения значения вinput
со следующими возможными значениями:'input'
- ввод с клавиатуры,'close-droppdown'
- закрылся дропдаун и значение сбросилось,'clear-by-button'
- значение очищено нажатием на кнопкуclear
. ВCalendarTime
в обработчикеonInputChange
, еслиreason !== 'iinput'
то дальше не обрабатываемRelease notes
Исправления
input
не србатывал колбэкonInputChange