Skip to content

Commit 444711d

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

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-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: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,30 @@ 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+
const inputRect = inputEl.getBoundingClientRect();
79+
const parentRect = (parentEl as HTMLElement).getBoundingClientRect();
80+
81+
clonedEl.style.top = `${inputRect.top - parentRect.top}px`;
82+
clonedEl.style.width = `${inputRect.width}px`;
83+
clonedEl.style.height = `${inputRect.height}px`;
84+
85+
if (isRTL) {
86+
clonedEl.style.right = `${parentRect.right - inputRect.right}px`;
87+
} else {
88+
clonedEl.style.left = `${inputRect.left - parentRect.left}px`;
89+
}
90+
7191
parentEl.appendChild(clonedEl);
7292
cloneMap.set(componentEl, clonedEl);
7393

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

0 commit comments

Comments
 (0)