Skip to content

Commit 8e3c109

Browse files
authored
fix: teardrop goes out of viewport when there is no gutter (#1343)
1 parent 0f8b249 commit 8e3c109

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ace/touchHandler.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,9 +684,17 @@ export default function addTouchListeners(editor, minimal, onclick) {
684684
const range = editor.getSelectionRange();
685685
const { pageX, pageY } = renderer.textToScreenCoordinates(range.start);
686686
const { lineHeight } = renderer;
687-
const [x, y] = relativePosition(pageX - teardropSize, pageY + lineHeight);
688687

689-
$start.style.left = `${x}px`;
688+
// Calculate desired position but ensure it stays within viewport
689+
let targetX = pageX - teardropSize;
690+
const [relativeX, y] = relativePosition(targetX, pageY + lineHeight);
691+
692+
// Ensure the teardrop doesn't go outside the left edge
693+
// Leave some padding (e.g., 4px) so it's not flush against the edge
694+
const minX = 4;
695+
const constrainedX = Math.max(relativeX, minX);
696+
697+
$start.style.left = `${constrainedX}px`;
690698
$start.style.top = `${y}px`;
691699

692700
if (!$start.isConnected) $el.append($start);

0 commit comments

Comments
 (0)