Skip to content

Commit

Permalink
Add docblock to PostTitle and PostTitleRaw component (#61740)
Browse files Browse the repository at this point in the history
* Add docblock to PostTitle component

* Refine PostTitle component JSDocs

* Add PostTitleRaw component JSDocs

* Add usePostTitle JSDocs

* Add usePostTitleFocus JSDocs

* Auto-generate editor docs for PostTitle updates

---------

Co-authored-by: Damon Cook <[email protected]>
  • Loading branch information
sanjucta and colorful-tones authored May 21, 2024
1 parent 538f18d commit dd4e2dd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/editor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,16 @@ Undocumented declaration.

### PostTitle

Undocumented declaration.
Renders the `PostTitle` component.

_Parameters_

- \_\_\_ `Object`: Unused parameter.
- _forwardedRef_ `Element`: Forwarded ref for the component.

_Returns_

- `Component`: The rendered PostTitle component.

### PostTitleRaw

Expand Down
9 changes: 8 additions & 1 deletion packages/editor/src/components/post-title/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import clsx from 'clsx';

/**
* WordPress dependencies
*/
Expand Down Expand Up @@ -211,4 +210,12 @@ function PostTitle( _, forwardedRef ) {
);
}

/**
* Renders the `PostTitle` component.
*
* @param {Object} _ Unused parameter.
* @param {Element} forwardedRef Forwarded ref for the component.
*
* @return {Component} The rendered PostTitle component.
*/
export default forwardRef( PostTitle );
8 changes: 8 additions & 0 deletions packages/editor/src/components/post-title/post-title-raw.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ import { DEFAULT_CLASSNAMES, REGEXP_NEWLINES } from './constants';
import usePostTitleFocus from './use-post-title-focus';
import usePostTitle from './use-post-title';

/**
* Renders a raw post title input field.
*
* @param {Object} _ Unused parameter.
* @param {Element} forwardedRef Reference to the component's DOM node.
*
* @return {Component} The rendered component.
*/
function PostTitleRaw( _, forwardedRef ) {
const { placeholder, hasFixedToolbar } = useSelect( ( select ) => {
const { getSettings } = select( blockEditorStore );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import { useSelect } from '@wordpress/data';
*/
import { store as editorStore } from '../../store';

/**
* Custom hook that manages the focus behavior of the post title input field.
*
* @param {Element} forwardedRef - The forwarded ref for the input field.
*
* @return {Object} - The ref object.
*/
export default function usePostTitleFocus( forwardedRef ) {
const ref = useRef();

Expand Down
5 changes: 5 additions & 0 deletions packages/editor/src/components/post-title/use-post-title.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import { useSelect, useDispatch } from '@wordpress/data';
*/
import { store as editorStore } from '../../store';

/**
* Custom hook for managing the post title in the editor.
*
* @return {Object} An object containing the current title and a function to update the title.
*/
export default function usePostTitle() {
const { editPost } = useDispatch( editorStore );
const { title } = useSelect( ( select ) => {
Expand Down

1 comment on commit dd4e2dd

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in dd4e2dd.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9181956844
📝 Reported issues:

Please sign in to comment.