Skip to content

Fix Figma-to-WordPress builder synchronization - #30

Open
Jan-CoreBunch wants to merge 1 commit into
CoreBunch:mainfrom
Jan-CoreBunch:fix/figma-to-wp-sync
Open

Fix Figma-to-WordPress builder synchronization#30
Jan-CoreBunch wants to merge 1 commit into
CoreBunch:mainfrom
Jan-CoreBunch:fix/figma-to-wp-sync

Conversation

@Jan-CoreBunch

Copy link
Copy Markdown
Contributor

What

  • Preserve the Figma plugin message envelope type when response payloads also contain a type field, preventing valid WordPress responses from being routed as the wrong message.
  • Wait for the CSS and preset writes to finish before synchronizing builder data, and pass the exact newly saved preset into that synchronization instead of reading potentially stale client state.
  • Run the classes endpoint even when a project generates no class selectors because that endpoint also refreshes builder variables. This keeps Bricks global-variable metadata, color swatches, and the Style Manager aligned with the current Core Framework CSS.
  • Normalize Figma class payloads by trimming, filtering, and deduplicating entries. An empty payload is now passed to builders as [] instead of [""], preventing blank Oxygen selectors without skipping Bricks variable refreshes.
  • Add regression coverage for empty Figma class payloads in both Oxygen and Bricks.

Why

Figma-to-WordPress writes could time out because a payload-level type replaced the outer routing type. Once that collision was fixed, builder synchronization still ran concurrently with the preset write and could use stale preset data. Classless projects also returned before calling the endpoint that refreshes Bricks variables, leaving Bricks' stored picker and Style Manager values stale even though applying var(--name) resolved to the current CSS value.

The Figma endpoint additionally converted an empty class string to a one-item array containing an empty selector. Normalizing it to a genuinely empty array keeps Oxygen selector data clean while retaining the builder refresh side effects required by Bricks.

Verification

  • vendor/bin/phpunit Tests: 38 tests, 73 assertions passed.
  • vendor/bin/phpunit Tests/BricksSynchronizationTest.php: 9 tests, 34 assertions passed.
  • bun run --filter './packages/figma' test: 18 tests passed.
  • bun run --filter './packages/www' build: passed.
  • bun run --filter './packages/figma' build: passed.
  • PHP syntax checks passed for the modified PHP source and test.
  • PHP coding-standard check reported zero errors; only existing unused-parameter warnings in test doubles remain.
  • git diff --check: passed.
  • Manually verified Figma desktop saves reach WordPress, Bricks variable metadata updates after reload, Oxygen Classic colors update, and Oxygen 6.1 synchronizes Core Framework classes, colors, and utility variables after Figma changes.

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.

1 participant