Skip to content

Conversation

@jamesmorrison
Copy link
Member

Description of the Change

Adds conditional check that the block (Tabs / Tab Items) exist on the post before enqueueing assets.

Closes #199

How to test the Change

  1. Create a page with the Tabs / Tab Items blocks
  2. Verify these load on frontend without issue
  3. Create a separate page without the Tabs / Tab Items blocks
  4. Confirm the assets /dist/blocks/tabs-item-block.js and /dist/blocks/tabs-block.css are not enqueued

Changelog Entry

Fixed - Bug fix since 1.3.4 noted in #199

Credits

Props @jamesmorrison

Checklist:

@github-actions github-actions bot added this to the Future Release milestone Aug 21, 2025
@github-actions github-actions bot added the needs:code-review This requires code review. label Aug 21, 2025
@jamesmorrison
Copy link
Member Author

@dkotter / @jeffpaul Please could you review this PR?

@jeffpaul jeffpaul requested a review from faisal-alvi August 21, 2025 14:26
@jeffpaul jeffpaul modified the milestones: Future Release, 1.4.0 Aug 21, 2025
Copy link
Collaborator

@dkotter dkotter left a comment

Choose a reason for hiding this comment

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

Couple typos that were preventing this from working properly on the front-end.

Once addressed, this does work and may be good enough. I am curious though, looking at the original issue, why this ends up loading the block editor script at all on the front-end? Seems like there may be a bigger issue here with how this block is built/registered that may be worth changing to fix the problem here

@jeffpaul
Copy link
Member

jeffpaul commented Sep 8, 2025

I am curious though, looking at the original issue, why this ends up loading the block editor script at all on the front-end? Seems like there may be a bigger issue here with how this block is built/registered that may be worth changing to fix the problem here

@fabiankaegy any insights from your perspective on this?

@fabiankaegy
Copy link
Member

I am curious though, looking at the original issue, why this ends up loading the block editor script at all on the front-end? Seems like there may be a bigger issue here with how this block is built/registered that may be worth changing to fix the problem here

@fabiankaegy any insights from your perspective on this?

Yeah ideally we should enqueue the assets via the viewScript field in block.json.

@jamesmorrison
Copy link
Member Author

@jeffpaul / @dkotter / @fabiankaegy Sorry it's taken so long for me to make the requested changes here.

I've refactored this to use the viewScript; tested and working locally.

I chose to leave the frontend.js file in case it's needed, let me know if you'd like this removed.

Please could you review the updates here?

@jeffpaul jeffpaul requested review from dkotter and fabiankaegy and removed request for faisal-alvi November 22, 2025 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:code-review This requires code review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tab and tab item blocks are loaded where they are not necessary

4 participants