-
Notifications
You must be signed in to change notification settings - Fork 473
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
🐞 - InputInline
has broken scroll in Safari / Firefox
#7552
Comments
Safari does not dispatch scroll events for inputs. We need to use additional keypress events, selection change events and whatnot to be able to adjust text-indent to input scroll. Maybe it's even easier to just use silent animation frame for polling, but that might cause a lot of CSS reflow. |
Just some intermediate investigationsWe can replace the following logic
with protected indent$ = merge(
fromEvent(this.element, 'scroll', {capture: true}), // Only Chrome emits this event for <input />
// Chrome does not fire `selectionchange` on deletion (but do it on insertion) ¯\_(ツ)_/¯
fromEvent(this.element, 'selectionchange', {capture: true}), // Firefox + Safari fallback
// Chrome & Safari scrolls input to the beginning on blur
// Firefox – keeps the same scrollLeft position on blur
fromEvent(this.element, 'focusout').pipe(
concatMap(
(x) => of(x).pipe(delay(0)), // Without delay `scrollLeft` is not yet updated
),
),
).pipe(
map(({target}) => target),
filter((x): x is HTMLInputElement => tuiIsElement(x) && tuiIsInput(x)),
map(
({scrollLeft}) => -scrollLeft - 1, // -1 for Safari (see styles)
),
); However, it still does fully solves all issue for Safari / Firefox.
Even if we delay update of textContent (by adding delay(0) to indent$ stream) - insertion of new character will be broken (we should increase size of ghost-span BEFORE textIndent calculations).
|
TODODiscuss this PR with @waterplea Which problem was solved by this PR ?
|
InputInline
has broken scroll in Safari / Firefox
Playground Link
No response
Description
Браузер - Safari.
Компонент - https://taiga-ui.dev/components/input-inline#heading
Шаги:
Ожидаемый результат: фокус установлен в конец строки, пользователь может передвигать курсор по тексту и редактировать его
Фактический результат: фокус остается на начале строки. Если пользователь работает с концом строки, то он не видит, что вводит
Angular version
No response
Taiga UI version
3.80.0
Which browsers have you used?
Which operating systems have you used?
The text was updated successfully, but these errors were encountered: