Skip to content

SearchControl: Deprecate onClose prop - #65988

Merged
mirka merged 5 commits into
WordPress:trunkfrom
Vrishabhsk:update/deprecate-onClose
Oct 10, 2024
Merged

mirka merged 5 commits into
WordPress:trunkfrom
Vrishabhsk:update/deprecate-onClose

Conversation

@Vrishabhsk

Copy link
Copy Markdown
Contributor

What?

  • Add @deprecated for onClose function prop for SearchControl component
  • Update README.md, JSDoc and StoryBook with _Note: this prop is deprecated._
  • When onClose prop is provided, execute deprecated from @wordpress/deprecated
  • Update test to expect console.warn when onClose is provided + fix should should typo

Why?

The onClose prop is not used anymore in the Gutenberg app
The prop itself is causing confusion to consumers (#64921),

How?

  • Soft Deprecates the onClose prop
  • Add deprecation notice in the SearchControl's docs
  • Execute deprecated when onClose is provided
  • Add test to expect deprecation warning

Testing Instructions

  • Clone the branch into the plugins directory of your WordPress installation
git clone https://github.com/Vrishabhsk/gutenberg/tree/update/deprecate-onClose
  • Build the files
cd gutenberg && npm install & npm build
  • Activate the Gutenbergplugin via the Plugins Admin Page.
  • Create a custom block
npx @wordpress/create-block@latest demo --variant=dynamic
  • Modify the edit.js to use SelectControl component
export default function Edit() {
	return (
		<p {...useBlockProps()}>
			<h1>Shut up</h1>
			<InspectorControls>
				<PanelBody title="Form Settings" initialOpen={false}>
					<PanelRow>
						<SearchControl
							label={__("Search posts")}
							onChange={(val) => {}}
						/>
					</PanelRow>
				</PanelBody>
			</InspectorControls>
		</p>
	);
}

@Vrishabhsk
Vrishabhsk requested a review from ajitbohra as a code owner October 9, 2024 12:02
@github-actions

github-actions Bot commented Oct 9, 2024 •

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: Vrishabhsk <vrishabhsk@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>

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

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 9, 2024
@github-actions

github-actions Bot commented Oct 9, 2024

Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @Vrishabhsk! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@ciampo
ciampo requested review from a team and mirka October 9, 2024 13:10

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looking good, thank you for contributing!

In case it's useful when contributing to wp-components in the future, we usually just spin up the Storybook (npm run storybook:dev) when testing things like this, without going through the hassle of making a test plugin 🙂

@mirka mirka added [Type] Code Quality Issues or PRs that relate to code quality [Package] Components /packages/components Needs Dev Note Requires a developer note for a major WordPress release cycle labels Oct 9, 2024
@mirka

mirka commented Oct 9, 2024

Copy link
Copy Markdown
Member

Could you also add a changelog entry please? Thanks!

Remove WithOnClose storybook variation. Refactor deprecation message. Add @ignore for onClose in types.ts. Add deprecations section in CHANGELOG.md
@Vrishabhsk
Vrishabhsk requested a review from mirka October 10, 2024 07:35
@Vrishabhsk
Vrishabhsk requested a review from ciampo October 10, 2024 09:18

@mirka mirka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Perfect, thank you!

@mirka
mirka enabled auto-merge (squash) October 10, 2024 11:22
@mirka
mirka merged commit 8d1dd6c into WordPress:trunk Oct 10, 2024
@github-actions github-actions Bot added this to the Gutenberg 19.5 milestone Oct 10, 2024
@mirka

mirka commented Oct 10, 2024

Copy link
Copy Markdown
Member

✍️ Dev Note

SearchControl: Deprecated onClose prop

This prop was originally intended for adding a custom click handler to the suffix button to close the search field entirely, rather than just clear the input value.

The pattern of repurposing the search clear button as a search close button is no longer used in WordPress, and is no longer recommended as a UI pattern since it can be confusing to users.

If you were relying on this prop, we recommend adding a separate close button to your UI.

@mirka mirka added has dev note when dev note is done (for upcoming WordPress release) [Type] Code Quality Issues or PRs that relate to code quality and removed Needs Dev Note Requires a developer note for a major WordPress release cycle [Type] Code Quality Issues or PRs that relate to code quality has dev note when dev note is done (for upcoming WordPress release) labels Oct 10, 2024
@mirka mirka added the has dev note when dev note is done (for upcoming WordPress release) label Oct 14, 2024
ciampo added a commit that referenced this pull request Oct 14, 2024
* Soft deprecate onClose function prop and execute deprecated

* Update README and StoryBook JSDoc

* Expect console.warn due to deprecated func call and fix typo

* Address PR feedback

Remove WithOnClose storybook variation. Refactor deprecation message. Add @ignore for onClose in types.ts. Add deprecations section in CHANGELOG.md

* Replace toHaveWarned with toHaveWarnedWith

Co-authored-by: Vrishabhsk <vrishabhsk@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
karthick-murugan pushed a commit to karthick-murugan/gutenberg that referenced this pull request Nov 13, 2024
* Soft deprecate onClose function prop and execute deprecated

* Update README and StoryBook JSDoc

* Expect console.warn due to deprecated func call and fix typo

* Address PR feedback

Remove WithOnClose storybook variation. Refactor deprecation message. Add @ignore for onClose in types.ts. Add deprecations section in CHANGELOG.md

* Replace toHaveWarned with toHaveWarnedWith

Co-authored-by: Vrishabhsk <vrishabhsk@git.wordpress.org>
Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
@Mamaduka Mamaduka mentioned this pull request Mar 12, 2025
45 of 49 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository has dev note when dev note is done (for upcoming WordPress release) [Package] Components /packages/components [Type] Code Quality Issues or PRs that relate to code quality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants