Skip to content

Commit 2d8e050

Browse files
committed
fix(input): prevent placeholder from overlapping start slot during scroll assist
1 parent 72826ed commit 2d8e050

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

core/src/components/input/input.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,7 @@
165165
// otherwise the .input-cover will not be rendered at all
166166
// The input cover is not clickable when the input is disabled
167167
.cloned-input {
168-
@include position(0, null, 0, 0);
169-
170168
position: absolute;
171-
172169
pointer-events: none;
173170
}
174171

core/src/components/textarea/textarea.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,7 @@
205205
// otherwise the .input-cover will not be rendered at all
206206
// The input cover is not clickable when the input is disabled
207207
.cloned-input {
208-
@include position(0, null, 0, 0);
209-
210208
position: absolute;
211-
212209
pointer-events: none;
213210
}
214211

core/src/utils/input-shims/hacks/common.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,29 @@ const addClone = (
6868
if (disabledClonedInput) {
6969
clonedEl.disabled = true;
7070
}
71+
72+
/**
73+
* Position the clone to match the native input's exact position and size
74+
* to prevent the placeholder from overlapping start slot content (e.g., icons).
75+
*/
76+
const doc = componentEl.ownerDocument!;
77+
const isRTL = doc.dir === 'rtl';
78+
79+
clonedEl.style.top = `${inputEl.offsetTop}px`;
80+
clonedEl.style.height = `${inputEl.offsetHeight}px`;
81+
82+
if (isRTL) {
83+
const parentWidth = (parentEl as HTMLElement).offsetWidth;
84+
const inputRight = parentWidth - inputEl.offsetLeft - inputEl.offsetWidth;
85+
clonedEl.style.right = `${inputRight}px`;
86+
} else {
87+
clonedEl.style.left = `${inputEl.offsetLeft}px`;
88+
}
89+
7190
parentEl.appendChild(clonedEl);
7291
cloneMap.set(componentEl, clonedEl);
7392

74-
const doc = componentEl.ownerDocument!;
75-
const tx = doc.dir === 'rtl' ? 9999 : -9999;
93+
const tx = isRTL ? 9999 : -9999;
7694
componentEl.style.pointerEvents = 'none';
7795
inputEl.style.transform = `translate3d(${tx}px,${inputRelativeY}px,0) scale(0)`;
7896
};

0 commit comments

Comments
 (0)