Skip to content

Commit 238a2c7

Browse files
authored
fix(wordsInput): prevent #wordsInput from overflowing the #wordsWrapper (@nadalaba) (#6610)
### Description in tape mode, if a long word is wider than the #wordsWrapper, then #wordsInput may overflow to the right causing a horizontal scroll to keep it in view. This limits its width so that it ends with the #wordsWrapper. https://github.com/user-attachments/assets/a9266407-a21c-43c0-9304-e683c6c2ce04
1 parent ec6e76b commit 238a2c7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

frontend/src/ts/test/test-ui.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,15 @@ export async function updateWordsInputPosition(initial = false): Promise<void> {
461461
const targetTop =
462462
activeWord.offsetTop + letterHeight / 2 - el.offsetHeight / 2 + 1; //+1 for half of border
463463

464+
if (Config.tapeMode !== "off") {
465+
const wordsWrapperWidth = (
466+
document.querySelector("#wordsWrapper") as HTMLElement
467+
).offsetWidth;
468+
el.style.maxWidth =
469+
wordsWrapperWidth * (1 - Config.tapeMargin / 100) + "px";
470+
} else {
471+
el.style.maxWidth = "";
472+
}
464473
if (activeWord.offsetWidth < letterHeight) {
465474
el.style.width = letterHeight + "px";
466475
} else {

0 commit comments

Comments
 (0)