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

Wait for the cell toolbar items to be rendered the first time before looking for overlap #16291

Merged
merged 3 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 9 additions & 4 deletions packages/cell-toolbar/src/celltoolbartracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,9 @@ export class CellToolbarTracker implements IDisposable {
return;
}

// Hide the toolbar by default, to avoid temporary overlapping.
cell.node.classList.add(TOOLBAR_OVERLAP_CLASS);

(cell.inputArea!.layout as PanelLayout).insertWidget(
0,
toolbarWidget
Expand Down Expand Up @@ -276,10 +279,12 @@ export class CellToolbarTracker implements IDisposable {
}

private _updateCellForToolbarOverlap(activeCell: Cell<ICellModel>) {
// When we do change in cell, If we don't wait the browser might not have
// completed the layout update, resulting in the previous width being returned
// using `getBoundingClientRect().width` in later functions.
requestAnimationFrame(() => {
// When we do change in cell, the browser might not have completed the layout
// update if we don't wait, resulting in the previous width being returned
// using `getBoundingClientRect().width` in later functions. This also wait for
// the toolbar to be rendered the first time (on page reload), allowing us to
// retrieve the right widgets width.
requestIdleCallback(() => {
// Remove the "toolbar overlap" class from the cell, rendering the cell's toolbar
const activeCellElement = activeCell.node;
activeCellElement.classList.remove(TOOLBAR_OVERLAP_CLASS);
Expand Down
Loading