Skip to content

fix(toolbar): align toolbar with stretched block content - #3058

Open
Anurag-S1ngh wants to merge 8 commits into
codex-team:nextfrom
Anurag-S1ngh:fix/2930-stretched-toolbar
Open

Anurag-S1ngh wants to merge 8 commits into
codex-team:nextfrom
Anurag-S1ngh:fix/2930-stretched-toolbar

Conversation

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor

Summary

Stretched blocks render their content across the full width, but the toolbar stayed aligned to the centered content width. The plus button and block tunes appeared far from the block's left edge.

Changes

  • Toggle a ce-toolbar--stretched modifier in Toolbar.moveAndOpen() based on the hovered block's stretched state, and remove it when the toolbar closes.
  • Widen the toolbar content to the stretched block width on desktop, with the matching RTL margin.

Testing

  • Built the bundle and reproduced the issue with a stretched block: before, block content was at 174px and 1142px wide while toolbar content stayed at 391px and 650px wide. After the change both are 174px and 1142px, and the plus button sits in the actions space at 116px.
  • Unstretching restores the normal centered toolbar position.
  • RTL: the toolbar content right edge matches the block content right edge.
  • eslint passes on the changed file. Stylelint reports only pre-existing indentation errors in these files.

Closes #2930

When a block is stretched, its content spans the full width, but the toolbar stayed aligned to the centered content width. Toggle a stretched modifier on the toolbar and match its content width to the block.

@neSpecc neSpecc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix, the approach looks right and minimal!

A few things besides the inline comments:

  • CHANGELOG: please add an entry to the 2.32.0 section of docs/CHANGELOG.md, e.g.
    `Fix` - Toolbar is now aligned with the content of stretched Blocks
  • Tests: please add a Cypress test to test/cypress/tests/api/toolbar.cy.ts:
    • hovering a stretched block → .ce-toolbar__content has the same left/width as that block's .ce-block__content;
    • toggling block.stretched via API while the toolbar is open over that block → toolbar re-aligns (see the inline comment).

Comment thread src/components/modules/toolbar/index.ts Resolved
Comment thread src/styles/toolbar.css Resolved
@Anurag-S1ngh

Copy link
Copy Markdown
Contributor Author

All four points are addressed in 0a180e65:

  • The stretched setter now emits BlockStretchToggled, and Toolbar re-runs moveAndOpen() when the changed block is the hovered one and the toolbar is open. Block Settings or Toolbox being open still blocks the move, same as BlockHovered.
  • Extracted --stretched-content-width and used it in block.css and toolbar.css, including the normal width min(). rtl.css already used the shared offset variable, so the calc is no longer repeated.
  • CHANGELOG entry added under 2.32.0.
  • Two Cypress tests in toolbar.cy.ts: alignment on hovering a stretched block, and re-alignment when stretched is toggled while the toolbar is open. Full suite passes locally, 377 tests.

The branch is merged with current next.

/**
* Do not move toolbar if Block Settings or Toolbox opened
*/
if (this.Editor.BlockSettings.opened || this.toolboxInstance?.opened) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Checked locally: stretching an image via the Image tool's Stretch tune still leaves the toolbar at the narrow column. The tune keeps Block Settings open after the click, so BlockStretchToggled arrives while settings are open and this early return skips it. Nothing re-applies the class after settings close either. Could you handle this case, e.g. just toggle ce-toolbar--stretched on the wrapper when settings are open (the popover is inside the toolbar and will move with it), or re-sync on Block Settings close? A test for it would be great too.

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor Author

Updated the toolbar to apply the stretched modifier before the Block Settings/Toolbox guard, so it realigns immediately while settings stay open. Added a Cypress test covering stretch and unstretch with Block Settings open. Also merged current next. Full Cypress suite passes, 379 tests.

@neSpecc neSpecc left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Now "stretch image" tune does nothing, please test it.

@Anurag-S1ngh

Copy link
Copy Markdown
Contributor Author

I could not reproduce this on c012be2. On the dev page at 1417px: hover the image block, open Block Settings, click Stretch image. The block gets ce-block--stretched, the image goes from 648px to 1040px, and the toolbar moves with it (left 383.5 to 216.5, width 650 to 1042). Clicking again restores it, and Block Settings stays open for both clicks. Which commit did you test? The dev page switched from SimpleImage to the Image tool in 4ea0f911, which only arrived here with the last merge of next, so a cached build would still load SimpleImage, which has no tunes.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stretched not working as expected on editorjs

2 participants