Skip to content

Commit

Permalink
fix for tab completion popup positioning
Browse files Browse the repository at this point in the history
  • Loading branch information
starpit committed Dec 10, 2018
1 parent 8fcb4ce commit 41768b8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/plugins/modules/core-support/src/lib/tab-completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,16 @@ const makeCompletionContainer = (block, prompt, partial, dirname?, lastIdx?) =>
// determine pixel width of current input value
const tmp = document.createElement('div')
tmp.style.display = 'inline-block'
tmp.style.fontSize = '0.925em'
tmp.style.opacity = '0'
tmp.style.position = 'absolute'
tmp.innerText = input.value.substring(0, input.selectionStart)
document.body.appendChild(tmp)
block.appendChild(tmp)
const inputWidth = tmp.clientWidth
document.body.removeChild(tmp)
block.removeChild(tmp)

const { left, width: containerWidth } = input.getBoundingClientRect()
const desiredLeft = left + inputWidth - 5
const desiredLeft = inputWidth + 12

if (desiredLeft + inputWidth < containerWidth) {
// the popup likely won't overflow to the right
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.tab-completion-temporary {
margin-top: 0.375em;
display: inline-block;
background: var(--color-field-01);
flex-direction: column;
Expand Down

0 comments on commit 41768b8

Please sign in to comment.