-
Notifications
You must be signed in to change notification settings - Fork 109
fix(money-input): caret position in integer part #1096
Conversation
…arui-feather into fix/money-input
src/money-input/money-input.tsx
Outdated
/** | ||
* Устанавливает каретку поля ввода в новую позицию. | ||
* | ||
* @param {Number} selection Новое положение каретки |
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.
nit: Может лучше описать на TypeScript:
private setInputSelection(selection: number) {
Ну и тогда из документации можно удалить {Number}
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.
Описал
src/money-input/money-input.tsx
Outdated
@@ -106,6 +111,8 @@ export class MoneyInput extends React.PureComponent<MoneyInputProps, MoneyInputS | |||
|
|||
root: HTMLInputElement; | |||
|
|||
private caretFixTimeout: ReturnType<typeof setTimeout> = null;; |
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.
private caretFixTimeout: ReturnType<typeof setTimeout> = null;; | |
private caretFixTimeout: ReturnType<typeof setTimeout> = null; |
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.
Поправил
|
Меньше зависимости от masked-input. |
README.md
Outdated
@@ -73,11 +73,11 @@ npm install arui-feather --save | |||
Шаги запуска демо: | |||
|
|||
1. `npm i` | |||
2. `npm run demo` |
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.
Почему это попало в чейнджи?
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.
@stepancar Поправлено
src/money-input/money-input.tsx
Outdated
// IE10 не умеет синхронно в событие `change` переставлять каретку. | ||
// Android chrome имеет дефект с автоматической установкой каретки | ||
// при использовании клавиатуры отличной от type="text". | ||
if (IS_IE9_10 || IS_ANDROID) { |
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.
@SiebenSieben IE11 у нас же уже
src/money-input/money-input.tsx
Outdated
componentWillUnmount() { | ||
if (this.caretFixTimeout) { | ||
clearTimeout(this.caretFixTimeout); | ||
this.caretFixTimeout = null; |
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.
Для чего эта проверка и установка прям перед дестроем этого флага в null?
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.
Переносил часть кода из masked-input.
Упростил
src/money-input/money-input.tsx
Outdated
@@ -20,6 +20,11 @@ const DEFAULT_FRACTION_SIZE = 2; | |||
const DEFAULT_INTEGER_SIZE = 9; | |||
const INTEGER_PART_SIZE = 3; | |||
|
|||
// В эту проверку попадают IE9 и IE10, которые не могут корректно работать с кареткой на событии `input`. | |||
const IS_IE9_10 = typeof window !== 'undefined' && !!(window as any).ActiveXObject; |
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.
Это надо убрать. IE 11
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.
Убрал
if (newValue.length > currentValue.length && newValue[currentSelection] === ',') { | ||
setTimeout((() => { | ||
|
||
// Фикс бага смещения каретки в браузере на андроидах Jelly Bean (c 4.1 по 4.3) |
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.
мы поддерживаем такие старые версии?
это вроде как устаревшие версии, которые были актулальны в 2013 (7 лет назад).
Есть какая-то статистика, в которой отображено сколько людей к нам заходит со старыми версиями андроида?
Мотивация и контекст
Решает issue #862