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

Wrap long signatures dynamically based on taken client width #2659

Merged
merged 5 commits into from
Sep 21, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ const wrapSymbolParameters = (symbol) => {
}

let symbolBlockWidth = symbol.clientWidth

// Even though the script is marked as `defer` and we wait for `DOMContentLoaded` event,
// it can happen that `symbolBlockWidth` is 0, indicating that something hasn't been loaded.
// Re-try after some time, should work. Should not go into infinite recursion because
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
// symbol blocks that have parameters definitely have width above 0
if (symbolBlockWidth === 0) {
setTimeout(function() {
wrapSymbolParameters(symbol);
}, 100)
}

let innerTextWidth = Array.from(symbol.children)
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
.filter(it => !it.classList.contains("block")) // blocks are usually on their own (like annotations), so ignore it
.map(it => it.getBoundingClientRect().width).reduce((a, b) => a + b, 0)
Expand Down