Skip to content

Fix block guard behavior in query loop blocks#1159

Merged
mauteri merged 5 commits intodevelopfrom
fix-block-guard-1
Aug 10, 2025
Merged

Fix block guard behavior in query loop blocks#1159
mauteri merged 5 commits intodevelopfrom
fix-block-guard-1

Conversation

@mauteri
Copy link
Copy Markdown
Contributor

@mauteri mauteri commented Aug 10, 2025

Description of the Change

Previously, the block guard feature had inconsistent behavior in query loop blocks. When enabled on a block within a query loop, it would only protect the first instance while leaving repeated instances across other posts unprotected. Additionally, all blocks of the same type would share the same guard state globally, causing unintended cross-contamination between different block contexts.

Fixes

  • ✅ Block guard now applies consistently across all repeated instances within the same query loop
  • ✅ Individual blocks outside query loops maintain independent guard states
  • ✅ Different block positions within the same query loop are independent (e.g., 1st RSVP vs 2nd RSVP)
  • ✅ No cross-contamination between blocks in different query loops or individual blocks

Testing

  1. Query Loop Test: Add a GatherPress block with block guard to a query loop template, toggle the guard on/off, verify it affects all repeated instances across posts
  2. Independence Test: Add multiple blocks of the same type in different contexts (individual blocks, different query loops, different positions), verify each has independent guard state
  3. Mixed Context Test: Have the same block type both inside and outside query loops, verify they don't affect each other

How to test the Change

Changelog Entry

Fixed - Bug fix

Credits

Props @mauteri

Checklist:

  • I agree to follow this project's Code of Conduct.
  • I have updated the documentation accordingly.
  • I have added tests to cover my change.
  • All new and existing tests pass.

@what-the-diff
Copy link
Copy Markdown

what-the-diff bot commented Aug 10, 2025

PR Summary

  • Integration of a Centralized State Management System
    This PR introduces a communal system that manages the settings of BlockGuard. This ensures consistency and harmony in operations across the network.

  • Transition from Local to Shared State Tracking
    The PR substitutes the localized state tracking of BlockGuard with the newly integrated shared system, resulting in uniformity across all similar block types.

  • Refinement of Block Targeting Methodology
    The PR has also refined the logic for targeting blocks within query loops. This allows for simultaneous control of multiple instances enhancing efficiency.

  • Revamping Focusable Elements Management and Visibility Control
    Focusable aspects handling and their visibility control have been overhauled for better functionality within the new shared state context.

  • Optimized Cleanup Procedure
    The PR includes a more effective cleanup process that efficiently removes overlays once a component is unmounted, especially when blocks belong to query loops.

@mauteri mauteri changed the title Fix Block Guard within Query block. Fix block guard behavior in query loop blocks Aug 10, 2025
@github-actions
Copy link
Copy Markdown
Contributor

Preview changes with Playground

You can preview the recent changes for PR#1159 with the following PHP versions:

PHP Version 8.3

PHP Version 7.4

Download .zip with build changes

Made with 💙 from GatherPress & a little bit of WordPress Playground. Changes will not persist between sessions.

@mauteri mauteri marked this pull request as ready for review August 10, 2025 18:32
@mauteri mauteri merged commit a0874c2 into develop Aug 10, 2025
10 checks passed
@mauteri mauteri deleted the fix-block-guard-1 branch August 10, 2025 20:08
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.

2 participants