Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions core/src/components/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,13 @@
// otherwise the .input-cover will not be rendered at all
// The input cover is not clickable when the input is disabled
.cloned-input {
@include position(0, null, 0, 0);

position: absolute;
top: 0;
bottom: 0;

// Reset height since absolute positioning with top/bottom handles sizing
height: auto;
max-height: none;

pointer-events: none;
}
Expand Down
8 changes: 6 additions & 2 deletions core/src/components/textarea/textarea.scss
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,13 @@
// otherwise the .input-cover will not be rendered at all
// The input cover is not clickable when the input is disabled
.cloned-input {
@include position(0, null, 0, 0);

position: absolute;
top: 0;
bottom: 0;

// Reset height since absolute positioning with top/bottom handles sizing
height: auto;
max-height: none;

pointer-events: none;
}
Expand Down
19 changes: 17 additions & 2 deletions core/src/utils/input-shims/hacks/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,26 @@ const addClone = (
if (disabledClonedInput) {
clonedEl.disabled = true;
}

/**
* Position the clone at the same horizontal offset as the native input
* to prevent the placeholder from overlapping start slot content (e.g., icons).
*/
const doc = componentEl.ownerDocument!;
const isRTL = doc.dir === 'rtl';

if (isRTL) {
const parentWidth = (parentEl as HTMLElement).offsetWidth;
const startOffset = parentWidth - inputEl.offsetLeft - inputEl.offsetWidth;
clonedEl.style.insetInlineStart = `${startOffset}px`;
} else {
clonedEl.style.insetInlineStart = `${inputEl.offsetLeft}px`;
}

parentEl.appendChild(clonedEl);
cloneMap.set(componentEl, clonedEl);

const doc = componentEl.ownerDocument!;
const tx = doc.dir === 'rtl' ? 9999 : -9999;
const tx = isRTL ? 9999 : -9999;
componentEl.style.pointerEvents = 'none';
inputEl.style.transform = `translate3d(${tx}px,${inputRelativeY}px,0) scale(0)`;
};
Expand Down
10 changes: 8 additions & 2 deletions core/src/utils/input-shims/hacks/scroll-assist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,14 @@ const jsSetFocus = async (
// give the native text input focus
relocateInput(componentEl, inputEl, false, scrollData.inputSafeY);

// ensure this is the focused input
setManualFocus(inputEl);
/**
* If focus has moved to another element while scroll assist was running,
* don't steal focus back. This prevents focus jumping when users
* quickly switch between inputs or tap other elements.
*/
if (document.activeElement === inputEl) {
setManualFocus(inputEl);
}

/**
* When the input is about to be blurred
Expand Down
Loading