Skip to content

fix(toolbar): keep the toolbar inside the editor when its top is negative - #3067

Open
Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2872-toolbar-negative-top
Open

Anurag-S1ngh wants to merge 1 commit into
codex-team:nextfrom
Anurag-S1ngh:fix/2872-toolbar-negative-top

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Summary

Closes #2872.

The toolbar top is computed from the Block offset plus the first input baseline. When a Tool lays out its input above the Block top, the computed value is negative and the toolbar is rendered outside the editor. The same happens with Blocks whose layout changes while the editor is loading.

Changes

  • Clamp the computed toolbar position to 0 so it never leaves the editor
  • Add data-cy="toolbar" to the toolbar element, as the existing TODO in the module asked, and use it in the test

Testing

  • New spec test/cypress/tests/ui/Toolbar.cy.ts uses a Tool with an input shifted 120px up and checks the toolbar top is not negative
  • Without the change the toolbar top is -124px and the test fails
  • yarn lint
  • npx cypress run --spec test/cypress/tests/ui/Toolbar.cy.ts
  • npx cypress run --spec test/cypress/tests/ui/toolbox.cy.ts
  • npx cypress run --spec test/cypress/tests/ui/BlockTunes.cy.ts
  • npx cypress run --spec test/cypress/tests/ui/InlineToolbar.cy.ts

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Toolbar can render outside of the EditorJS component

1 participant