Skip to content

Commit 164679b

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

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

core/src/components/input/input.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,10 @@
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;
171169

170+
// Position is set in JS to match the native input's offset.
171+
172172
pointer-events: none;
173173
}
174174

core/src/components/textarea/textarea.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@
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;
211209

210+
// Position is set in JS to match the native input's offset.
211+
212212
pointer-events: none;
213213
}
214214

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,28 @@ const addClone = (
6868
if (disabledClonedInput) {
6969
clonedEl.disabled = true;
7070
}
71+
72+
/**
73+
* Position the clone at the same offset as the native input to prevent the
74+
* 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+
81+
if (isRTL) {
82+
const parentWidth = (parentEl as HTMLElement).offsetWidth;
83+
const inputRight = parentWidth - inputEl.offsetLeft - inputEl.offsetWidth;
84+
clonedEl.style.right = `${inputRight}px`;
85+
} else {
86+
clonedEl.style.left = `${inputEl.offsetLeft}px`;
87+
}
88+
7189
parentEl.appendChild(clonedEl);
7290
cloneMap.set(componentEl, clonedEl);
7391

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

0 commit comments

Comments
 (0)