Skip to content

Commit

Permalink
fix(legacy): trigger transform placeholder when using autofill (#8779)
Browse files Browse the repository at this point in the history
  • Loading branch information
splincode authored Sep 2, 2024
1 parent 6604fd6 commit 464dee4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const TUI_ICON_START_PADDINGS: Record<TuiSizeL | TuiSizeS, number> = {
'options.appearance() === "table" || controller.labelOutside',
'(focusin)': 'onFocused(true)',
'(focusout)': 'onFocused(false)',
'(transitionstart.capture)': 'transitionStartHandler($event)',
},
})
export class TuiPrimitiveTextfieldComponent
Expand Down Expand Up @@ -271,6 +272,15 @@ export class TuiPrimitiveTextfieldComponent
nativeFocusableElement.focus();
}

protected transitionStartHandler({propertyName, target}: TransitionEvent): void {
const matchedAutofill =
propertyName.includes('box-shadow') && (target as Element)?.matches('input');

if (matchedAutofill) {
this.onAutofilled(!this.autofilled);
}
}

protected onAutofilled(autofilled: boolean): void {
this.updateAutofilled(autofilled);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
.textfield();

:host {
::ng-deep input {
// @note: need for listen (transitionstart) event
// don't use more than one listener property
transition: box-shadow 0.01s;
}

&._autofilled {
&[data-size='s'] .t-placeholder,
&._label-outside .t-placeholder,
Expand Down

0 comments on commit 464dee4

Please sign in to comment.