-
Notifications
You must be signed in to change notification settings - Fork 2
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
feat: focusOptions changes, replaced focusName - with field and index, added focusOptions to all array methods #103
Conversation
…, added focusOptions to all array methods
@@ -110,13 +110,11 @@ export default { | |||
|
|||
this.fieldComponents.splice(index, 1); | |||
}, | |||
handleFocus({ focusName }) { | |||
handleFocus({ field, index }) { |
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.
Может тут тогда индекс по умолчанию присваивать в 0? Всё равно ниже это и делаешь :)
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.
Возможно стоит бросать исключение, если не передан field, иначе не понятно что фокусировать :) Что думаешь?
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.
Угу, добавил ошибку если field
не передан, возможно нужно указать явно undefined
, но вроде как name не может быть пустой строкой по этому закинул более простую проверку
дефолтное значение на index тоже закинул
|
||
if (focusOptions && this.fields.length) { | ||
// by default focus on previous field, if there is no previous field focus on first field | ||
this.handleFocus({ index: index - 1 || 0, ...focusOptions }); |
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.
Если index будет 0, то у тебя фокусировать будет -1 элемент :)
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.
И вправду проглядел :) Спасибо! поправил
…, added focusOptions to all array methods
…, added focusOptions to all array methods
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.
Чётко!
Поменял
focusOptions
, убралfocusName
, и добавилfield
иindex
как 2 отдельных поляТак же добавил
focusOptions
для каждого метода массива, и установил дефолтные индексы при передачеfield
(Дефолтный индекс срабатывает если передаём название поля, но не передаём индекс)
Дефолтный индекс указывал по следующему принципу - "то что последнее изменили"
append
- фокус на добавленное (последнее) полеinsert
- фокус на добавленное (указанное) полеmove
- фокус на перемещённое (to) полеswap
- фокус на перемещённое (to) полеremove
- фокус на предыдущее (если нет предыдущего то на первое) поле+Покрыл это тестами