Skip to content

Block Grid: Fix inline create button width not updating on workspace resize (closes #22527)#22928

Merged
AndyButland merged 4 commits into
v17/devfrom
v17/bugfix/block-grid-inline-width-resize
May 21, 2026
Merged

Block Grid: Fix inline create button width not updating on workspace resize (closes #22527)#22928
AndyButland merged 4 commits into
v17/devfrom
v17/bugfix/block-grid-inline-width-resize

Conversation

@engijlr

@engijlr engijlr commented May 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The <uui-button-inline-create> element had its width measured once at render time and applied as an inline style, which was never updated when the workspace was resized
  • Added a ResizeObserver on the layout container to re-measure and update the width whenever the container changes size
  • Added disconnectedCallback to disconnect the observer

How to test:

  1. Create a Document Type with a Block Grid property configured with 4 columns
  2. Add a block type with column span options
  3. Create a content node and add 3+ blocks
  4. Hover between blocks, verify the inline create line spans the full container width
  5. Drag the content tree panel wider/narrower to resize the workspace
  6. Verify no horizontal scrollbar appears in the block grid
  7. Hover between blocks again after resize, verify the inline create line still spans the full container width

Fixes #22527

@claude

claude Bot commented May 21, 2026

Copy link
Copy Markdown

Claude finished @engijlr's task in 3m 18s —— View job


PR Review

Target: origin/v17/dev · Based on commit: cf6051ef · Skipped: 0 noise files out of 1 total

Adds a ResizeObserver on the Block Grid layout container so the inline create button width is recalculated whenever the container resizes, fixing the stale width that caused horizontal overflow after workspace resize.


Important

  • block-grid-entry.element.ts:352: No tests added. Coding preferences require blackbox tests for changed code. For a ResizeObserver-driven fix, a browser-environment test using ResizeObserver mock or a Lit component test verifying the observer is wired up and torn down would provide coverage. Fix this →

Suggestions

  • block-grid-entry.element.ts:358: Missing destroy() override. The only other component in the codebase using ResizeObserverscrollable-container.element.ts — also overrides destroy() to disconnect the observer alongside disconnectedCallback(). The destroy() hook is the Umbraco element teardown path (e.g. on route changes) and can be called independently of the DOM lifecycle. Without it, the observer survives explicit element teardown until GC.

    override destroy(): void {
        this.#layoutContainerResizeObserver?.disconnect();
        this.#layoutContainerResizeObserver = undefined;
        super.destroy();
    }
  • block-grid-entry.element.ts:352: Observer re-instantiated on each reconnect. The sibling pattern (see scrollable-container.element.ts:12) initialises #resizeObserver once as a class field and calls .observe() / .disconnect() per lifecycle event. The PR creates a new ResizeObserver (plus a new .bind(this) closure) every time connectedCallback fires. Consider initialising the observer as a class field and only calling .observe() / .disconnect() in the lifecycle hooks.

    // class field:
    #layoutContainerResizeObserver = new ResizeObserver(this.#callUpdateInlineCreateButtons.bind(this));
    
    // in connectedCallback — replace the creation block with:
    if (this.parentElement) {
        this.#layoutContainerResizeObserver.observe(this.parentElement);
    }
    
    // in disconnectedCallback:
    this.#layoutContainerResizeObserver.disconnect();
    // (no need to set to undefined since it's a fixed instance)

Approved with Suggestions for improvement

Good to go, but please carefully consider the importance of the suggestions.

Labels applied: area/frontend, category/ux

@claude claude Bot added the category/ux User experience label May 21, 2026

@AndyButland AndyButland left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works nicely @engijlr - I've tested, replicate the issue before the fix and confirmed that it's resolved afterwards.

@AndyButland AndyButland merged commit 82b2991 into v17/dev May 21, 2026
30 checks passed
@AndyButland AndyButland deleted the v17/bugfix/block-grid-inline-width-resize branch May 21, 2026 16:11
AndyButland pushed a commit that referenced this pull request May 21, 2026
…resize (closes #22527) (#22928)

* Add ResizeObserver for inline create buttons

* Disconnect layout resize observer on destroy

* Initialize ResizeObserver and simplify cleanup

* Remove optional chaining on layout observer disconnect
AndyButland pushed a commit that referenced this pull request May 21, 2026
…resize (closes #22527) (#22928)

* Add ResizeObserver for inline create buttons

* Disconnect layout resize observer on destroy

* Initialize ResizeObserver and simplify cleanup

* Remove optional chaining on layout observer disconnect
@AndyButland

Copy link
Copy Markdown
Contributor

Cherry picked into release/17.5.0 and release/18.0.

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.

2 participants