Skip to content

fix(ui): add Below action respects filterOptions in blocks field#15918

Open
ossaidqadri wants to merge 2 commits intopayloadcms:mainfrom
ossaidqadri:fix/blocks-add-below-filterOptions
Open

fix(ui): add Below action respects filterOptions in blocks field#15918
ossaidqadri wants to merge 2 commits intopayloadcms:mainfrom
ossaidqadri:fix/blocks-add-below-filterOptions

Conversation

@ossaidqadri
Copy link
Contributor

Fixes #15829

@ossaidqadri ossaidqadri requested a review from denolfe as a code owner March 11, 2026 21:01
Copilot AI review requested due to automatic review settings March 11, 2026 21:01
@ossaidqadri ossaidqadri changed the title fix(ui): Add Below action respects filterOptions in blocks field fix(ui): add Below action respects filterOptions in blocks field Mar 11, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a Payload Admin UI bug where the Blocks field “Add Below” row action did not respect filterOptions, causing the drawer to show unfiltered blocks.

Changes:

  • Pass filtered block options down to row-level actions so “Add Below” uses the same filtered list as the main “Add content” button.
  • Update RowActions to prefer filteredBlocks when rendering the BlocksDrawer.
  • Adjust root package.json workspace/overrides configuration (not directly related to the UI fix).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/ui/src/fields/Blocks/index.tsx Passes filtered blocks to each row so row actions can respect filterOptions.
packages/ui/src/fields/Blocks/BlockRow.tsx Threads filteredBlocks through to RowActions.
packages/ui/src/fields/Blocks/RowActions.tsx Uses filteredBlocks for the row-level drawer to fix “Add Below” filtering.
package.json Updates workspace paths and moves dependency overrides configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

package.json Outdated
Comment on lines 248 to 256
"overrides": {
"copyfiles": "$copyfiles",
"cross-env": "$cross-env",
"dotenv": "$dotenv",
"graphql": "16.8.1",
"react": "$react",
"react-dom": "$react-dom",
"typescript": "$typescript"
}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The repo appears to use pnpm-specific configuration for dependency overrides (e.g. test/package.json uses pnpm.overrides). Moving overrides to the root-level overrides key may not be consistently applied by pnpm tooling and diverges from the existing pattern—consider keeping these under pnpm.overrides for consistency and to avoid installs behaving differently across workspaces.

Copilot uses AI. Check for mistakes.
}}
addRowIndex={rowIndex}
blocks={blocks}
blocks={filteredBlocks || blocks}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

This change fixes the UI behavior, but there doesn’t appear to be an e2e regression test covering the "Add Below" row action respecting filterOptions (current conditional blocks tests only cover the bottom "Add content" drawer). Adding a Playwright assertion in test/fields/collections/Blocks/e2e.spec.ts would prevent this from regressing again.

Suggested change
blocks={filteredBlocks || blocks}
blocks={filteredBlocks ?? blocks}

Copilot uses AI. Check for mistakes.
Comment on lines 6 to 13
"workspaces": [
"packages/*",
"test/*"
"tools/*",
"test",
"templates/blank",
"templates/website",
"templates/ecommerce"
],
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

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

The PR is scoped to a UI bugfix (Blocks "Add Below" respecting filterOptions), but this change also rewrites the root workspaces list. If this is intentional housekeeping, it would be better split into a separate PR (or called out explicitly in the PR description) to keep the fix focused and reduce release risk.

Copilot uses AI. Check for mistakes.
- Move overrides to pnpm.overrides for pnpm consistency
- Use nullish coalescing (??) instead of OR (||) in RowActions
- Add e2e test verifying Add Below respects filterOptions
- Revert unrelated workspaces changes to keep PR focused
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.

Add Below does not filter blocks with filterOptions

2 participants