Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: terms extend beyond right edge of screen #447

Merged
merged 7 commits into from
Jul 1, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/js/term/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,23 @@
const fitDefinitionDocument =
isAlignSwapped && !definitionOutOfScreenOnLeft ? definitionWidth - termWidth : 0;
const customHeaderTop = getCoords(definitionParent).top - definitionParent.offsetTop;

Check failure on line 89 in src/js/term/utils.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Delete `····`
const offsetRight = 5

Check failure on line 90 in src/js/term/utils.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Insert `;`
const shiftLeft = definitionOutOfScreenOnRight ? (definitionRightCoordinate - document.body.clientWidth + offsetRight) : 0

Check failure on line 91 in src/js/term/utils.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Replace `·?·(definitionRightCoordinate·-·document.body.clientWidth·+·offsetRight)·:·0` with `⏎········?·definitionRightCoordinate·-·document.body.clientWidth·+·offsetRight⏎········:·0;`
const leftOffset =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it would be better to adhere to the same logic for naming variables, you have offsetRight shiftLeft and leftOffset, I suggest doing it offestLeft

getCoords(termElement).left -
definitionParentLeft +
definitionParent.offsetLeft -
fitDefinitionDocument

Check failure on line 96 in src/js/term/utils.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Insert `;`

const isShiftLeftNeeded = leftOffset + definitionWidth >= document.body.clientWidth;

definitionElement.style.top =
Number(getCoords(termElement).top + offsetTop - customHeaderTop) + 'px';
definitionElement.style.left =
Number(
getCoords(termElement).left -
definitionParentLeft +
definitionParent.offsetLeft -
fitDefinitionDocument,
) + 'px';
definitionElement.style.left = Number(

Check failure on line 102 in src/js/term/utils.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Replace `⏎········leftOffset·-⏎········(isShiftLeftNeeded·?·shiftLeft·:·0)⏎····` with `leftOffset·-·(isShiftLeftNeeded·?·shiftLeft·:·0)`
leftOffset -
(isShiftLeftNeeded ? shiftLeft : 0)
) + 'px';
}

function termOnResize() {
Expand Down
Loading