Skip to content

Docs: Add Block Actions Readme - #69408

Merged
im3dabasia merged 3 commits into
WordPress:trunkfrom
dhruvikpatel18:add/block-actions-readme
Aug 12, 2026
Merged

Docs: Add Block Actions Readme#69408
im3dabasia merged 3 commits into
WordPress:trunkfrom
dhruvikpatel18:add/block-actions-readme

Conversation

@dhruvikpatel18

Copy link
Copy Markdown
Member

What?

Part of: #22891

Why?

This PR adds the README for Block Actions component

Testing Instructions

none

Screenshots or screencast

none

@dhruvikpatel18
dhruvikpatel18 marked this pull request as ready for review March 4, 2025 11:45
@dhruvikpatel18
dhruvikpatel18 requested a review from ellatrix as a code owner March 4, 2025 11:45
@github-actions

github-actions Bot commented Mar 4, 2025

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org>
Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Mamaduka Mamaduka added the [Type] Developer Documentation Documentation for developers label Mar 5, 2025
@github-actions github-actions Bot added the [Package] Block editor /packages/block-editor label Aug 11, 2026

@im3dabasia im3dabasia 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.

@dhruvikpatel18 , Thanks for picking this up!

Left a few feedbacks. Please address them. If you have any doubts please ping me.

The Dependencies, Features, and trailing "For more details…" sections don't appear in other READMEs Could those go?

| ------------------------------- | ---------- | -------------------------------------------------------------------- |
| `clientIds` | `string[]` | Array of block client IDs to perform actions on. |
| `children` | `function` | A render prop function that receives available actions as an object. |
| `__experimentalUpdateSelection` | `function` | (Experimental) Function to update block selection after an action. |

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.

__experimentalUpdateSelection is documented as a function, but it's a boolean, it's passed straight through as the 2nd arg to duplicateBlocks( clientIds, updateSelection = true ).

Would boolean, default true, be more accurate?

Comment on lines +28 to +41
### Provided Actions

The `children` function receives an object with the following properties, which can be used to trigger block actions:

| Action | Type | Description |
| ---------------- | --------------------- | ------------------------------------------------------ |
| `onDuplicate` | `() => void` | Duplicates the selected blocks. |
| `onRemove` | `() => void` | Removes the selected blocks. |
| `onInsertBefore` | `() => void` | Inserts a new block before the selected blocks. |
| `onInsertAfter` | `() => void` | Inserts a new block after the selected blocks. |
| `onGroup` | `() => void` | Groups the selected blocks into a container block. |
| `onUngroup` | `() => void` | Ungroups a grouped block, extracting its inner blocks. |
| `onCopy` | `() => void` | Copies the selected block(s) for later pasting. |
| `onPasteStyles` | `() => Promise<void>` | Pastes styles from copied blocks. |

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.

One more thought on structure, the render prop values are currently in their own "Provided Actions" section.

Could they live under children in ###Props instead? That's what Dropdown does for its renderContent callback args, and it keeps everything the consumer touches in one place.

Only hesitation is that Dropdown has 3 args and this has 12, so nested bullets might get hard to scan, your call on which reads better.

Either way though, "Provided Actions" isn't quite right for the four can* flags.

| `onInsertAfter` | `() => void` | Inserts a new block after the selected blocks. |
| `onGroup` | `() => void` | Groups the selected blocks into a container block. |
| `onUngroup` | `() => void` | Ungroups a grouped block, extracting its inner blocks. |
| `onCopy` | `() => void` | Copies the selected block(s) for later pasting. |

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.

onCopy doesn't actually copy, it only flashes the block; the clipboard write lives in the consumer. Worth rewording?

@@ -0,0 +1,71 @@
## Block Actions

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.

  • The heading is ##; nearly all component READMEs here start with # (markdownlint flags it as MD041 too).

Comment on lines +20 to +23
### Props

| Prop | Type | Description |
| ------------------------------- | ---------- | -------------------------------------------------------------------- |

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.

Follow the block-editor README format.

Siblings use
## Development guidelines### Usage### Props#### propName with - **Type:**, not a markdown table, see dimension-control/README.md and height-control/README.md.

### Usage

```jsx
import BlockActions from './block-actions';

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.

The usage example's import BlockActions from './block-actions' won't work for a reader, the component isn't exported from @wordpress/block-editor at all. Its only consumer imports it relatively. Worth a note that it's component-internal?

Comment on lines +34 to +35
| `onDuplicate` | `() => void` | Duplicates the selected blocks. |
| `onRemove` | `() => void` | Removes the selected blocks. |

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.

onDuplicate / onRemove are typed () => void but both return the dispatch result. Minor, but onPasteStyles got it right so the inconsistency stands out.

---

For more details, refer to the [WordPress Gutenberg repository](https://github.com/WordPress/gutenberg).

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.

Many of these READMEs close with the standard "Block Editor components … can only be used under a BlockEditorProvider" footer. Might be worth adding for consistency.

Here is the clause

Block Editor components are components that can be used to compose the UI of your block editor. Thus, they can only be used under a [BlockEditorProvider](https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/provider/README.md) in the components tree.

Comment on lines +59 to +62
### Related Components

- `usePasteStyles` – Used to handle copying and pasting block styles.
- `block-editor/store` – The primary store for managing block actions.

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.

We can probably remove this. Doesn't add value imo. What do you think?

Related Components lists usePasteStyles (a hook, and it only pastes, it doesn't copy) and block-editor/store (a store, not a component).

Comment on lines +68 to +70
---

For more details, refer to the [WordPress Gutenberg repository](https://github.com/WordPress/gutenberg).

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.

The trailing --- + "For more details, refer to the WordPress Gutenberg repository" isn't present in any other README and reads as filler.

I think we can do away with this?

@im3dabasia im3dabasia 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.

LGTM ✅

Thanks for working on this!

@im3dabasia
im3dabasia merged commit ac8de62 into WordPress:trunk Aug 12, 2026
43 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.8 milestone Aug 12, 2026
shail-mehta pushed a commit that referenced this pull request Aug 12, 2026
* Docs: Add Block Actions Readme
* Docs: Update README for BlockActions component with clearer usage and props details

Co-authored-by: dhruvikpatel18 <dhruvik18@git.wordpress.org>
Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants