Skip to content

Commit d497922

Browse files
committed
editor: suggestion on right must remain on the screen fix #271
1 parent c37dcb8 commit d497922

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

addon/editor.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,13 @@ export class Editor extends React.Component {
296296
let caretEle = model.editorMirror.getElementsByClassName("editor_caret")[0];
297297
if (caretEle) {
298298
const rect = caretEle.getBoundingClientRect();
299-
model.setSuggestionPosition(rect.top + rect.height, rect.left);
299+
const textareaRect = model.editor.getBoundingClientRect();
300+
let suggestionLeft = rect.left;
301+
// If caret's right edge is too close to the left of textarea, position suggestion to the left of caret
302+
if (rect.left + 200 > textareaRect.right) {
303+
suggestionLeft = textareaRect.right - 200;
304+
}
305+
model.setSuggestionPosition(rect.top + rect.height, suggestionLeft);
300306
} else {
301307
model.displaySuggestion = false;
302308
}

0 commit comments

Comments
 (0)