mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-06 02:55:40 +08:00
### Description This PR fixes two related caret positioning issues that occurred **before any user input**: * **Resize Bug**: Resizing the browser immediately after a page refresh caused the caret to appear misaligned. The position only corrected itself after the user typed the first character. * **Navigation Bug**: Navigating away from the test page and back (especially after a refresh) caused the caret to initially render in the wrong position, then animate into place. --- ### Solution * Refactor `Caret.updatePosition()` to use `getComputedStyle` for width/height instead of `getBoundingClientRect()` and `offsetHeight` makes caret positioning more accurate. * Redundant calls to Caret.updatePosition() have been removed from the resize handler, relying instead on the more comprehensive caret re-initialization. These changes resolve caret alignment and animation issues after loading, resizing, or navigating, including in tape mode. --- > ~~Replaced early calls to `Caret.updatePosition()` with `Caret.show()` when no input has been entered yet.~~ > ~~`Caret.show()` ensures the caret is:~~ > ~~* Visible~~ > ~~* Properly initialized~~ > ~~* Animated via `startAnimation()`~~ > ~~* Positioned correctly via internal `updatePosition()` call~~ > ~~Once the caret is initialized (i.e., after first input), we continue using `updatePosition()` directly for subsequent updates.~~ > --- Closes #6639 |
||
|---|---|---|
| .. | ||
| __tests__ | ||
| docker | ||
| scripts | ||
| src | ||
| static | ||
| .eslintrc.cjs | ||
| .firebaserc_example | ||
| .oxlintrc.json | ||
| firebase.json | ||
| gulpfile.js | ||
| knip.json | ||
| package.json | ||
| tsconfig.json | ||
| vite.config.dev.js | ||
| vite.config.js | ||
| vite.config.prod.js | ||
| vitest.config.js | ||