Skip to content
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(kit): InputInline has broken scroll in Safari & Firefox #9818

Merged
merged 3 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<ul class="task">
<ol>
I
<tui-input-inline>
<input ngModel="am" />
</tui-input-inline>
funny.
</ol>

<ol>
He
<tui-input-inline [class._empty]="!answer">
<!-- Any text inside tui-input-inline is placeholder-->
<!-- It will be shown fully even for unset width of InputInline -->
___
<input [(ngModel)]="answer" />
</tui-input-inline>
funny.
</ol>

<ol>
You
<tui-input-inline [style.max-width.ch]="15">
<input
ngModel=""
placeholder="___"
/>
</tui-input-inline>
funny.
</ol>
</ul>

<section class="task">
<p>
<strong>Writing practice</strong>
<br />
Learning to
<s>write</s>
type underscore and hyphen
</p>
<!-- prettier-ignore -->
<div>
___<tui-input-inline>
<input
ngModel=""
placeholder="___"
/>
</tui-input-inline>------<tui-input-inline>
<input
ngModel=""
placeholder="------"
/>
</tui-input-inline>
</div>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.task:first-child input:not(:placeholder-shown) {
text-decoration: underline;
text-align: center;
}

tui-input-inline._empty,
tui-input-inline:has(input:placeholder-shown) {
color: var(--tui-text-tertiary);
}

tui-input-inline:has(input[placeholder]) {
min-inline-size: 3ch;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import {Component} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {changeDetection} from '@demo/emulate/change-detection';
import {encapsulation} from '@demo/emulate/encapsulation';
import {TuiInputInline} from '@taiga-ui/kit';

@Component({
standalone: true,
imports: [FormsModule, TuiInputInline],
templateUrl: './index.html',
styleUrls: ['./index.less'],
encapsulation,
changeDetection,
})
export default class Example {
protected answer = '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import {TuiDemo} from '@demo/utils';
changeDetection,
})
export default class Page {
protected readonly examples = ['Basic', 'Heading', 'External update'];
protected readonly examples = ['Basic', 'Heading', 'External update', 'Inside text'];
}
12 changes: 0 additions & 12 deletions projects/kit/components/input-inline/input-inline.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import {NgControl} from '@angular/forms';
import {TuiLet} from '@taiga-ui/cdk/directives/let';
import {tuiControlValue} from '@taiga-ui/cdk/observables';
import {tuiIsElement, tuiIsInput} from '@taiga-ui/cdk/utils/dom';
import {defer} from 'rxjs';

@Component({
Expand All @@ -19,21 +18,10 @@ import {defer} from 'rxjs';
styleUrls: ['./input-inline.style.less'],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
'(scroll.capture)': 'onScroll($event.target)',
},
})
export class TuiInputInline {
@ContentChild(NgControl)
private readonly control?: NgControl;

protected readonly value$ = defer(() => tuiControlValue(this.control!));

protected indent = -1;

protected onScroll(target: EventTarget | null): void {
if (tuiIsElement(target) && tuiIsInput(target)) {
this.indent = -target.scrollLeft - 1; // -1 for Safari (see styles)
splincode marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
tui-input-inline {
position: relative;
display: inline-block;
overflow: hidden;
white-space: nowrap;
box-sizing: border-box;

Expand All @@ -12,10 +11,10 @@ tui-input-inline {
}

> .t-before {
display: block;
padding-right: 0.02em; // to prevent caret shaking
margin-left: 1px; // to prevent hiding characters in safari
white-space: pre;
visibility: hidden;
}

> .t-placeholder {
Expand All @@ -30,7 +29,7 @@ tui-input-inline {
background-color: transparent;
padding: inherit;
font: inherit;
-webkit-text-fill-color: transparent;
color: inherit;
box-sizing: border-box;
inline-size: 100%;
block-size: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<ng-container *tuiLet="value$ | async as value">
<span
class="t-before"
[style.text-indent.px]="indent"
[textContent]="value"
></span>

Expand Down
Loading