Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit Experimental APIs for WP 6.2 #47196

Closed
12 of 14 tasks
ntsekouras opened this issue Jan 16, 2023 · 32 comments
Closed
12 of 14 tasks

Audit Experimental APIs for WP 6.2 #47196

ntsekouras opened this issue Jan 16, 2023 · 32 comments
Labels
Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues.

Comments

@ntsekouras
Copy link
Contributor

ntsekouras commented Jan 16, 2023

Cc @WordPress/gutenberg-core

APIs that never released in a stable WP version

This is a first pass of the new APIs based on this diff that compares the APIs in 6.1.

All experimental APIs

Generated using @noisysocks' script from #28157, with a small tweak to add each API only once, in the first package it was found.

I'm sharing the suggestions from previous similar issues(example) for older WP versions by @youknowriad in #31416, although we need to evaluate per case the proper handling:

  • If it's an API that is never meant to be made available to third-party developers as is, rename it to __unstable instead
  • If you think it's time to consider making the API stable, open a PR to rename it and soft deprecate it for two version(example PR).
  • If you think it's an API worth having, but you're still uncertain whether future changes might impact it, consider asking for help to make the right call, or comment here.
  • if you want to give the API more time to mature, just ignore it for now.

The list will be updated again, since APIs might change before the last GB version to be included in 6.2.

List of experimental APIs

packages/annotations

__experimentalAddAnnotation
__experimentalCreateOnChangeEditableValue
__experimentalCreatePrepareEditableTree
__experimentalGetAllAnnotationsForBlock
__experimentalGetAnnotations
__experimentalGetAnnotationsForBlock
__experimentalGetAnnotationsForRichText
__experimentalGetPropsForEditableTreeChangeHandler
__experimentalGetPropsForEditableTreePreparation
__experimentalRemoveAnnotation
__experimentalRemoveAnnotationsBySource
__experimentalUpdateAnnotationRange

packages/block-directory

__experimentalIsFocusable

packages/block-editor

__experimentalAlignmentMatrixControl
__experimentalAppenderTagName
__experimentalApplyValueToSides
__experimentalBlockAlignmentMatrixControl
__experimentalBlockDirectory
__experimentalBlockFullHeightAligmentControl
__experimentalBlockPatternCategories
__experimentalBlockPatternSetup
__experimentalBlockPatterns
__experimentalBlockPatternsList
__experimentalBlockVariationPicker
__experimentalBlockVariationTransforms
__experimentalBorder
__experimentalBorderBoxControl
__experimentalBorderRadiusControl
__experimentalBoxControl
__experimentalCanUserUseUnfilteredHTML
__experimentalCaptureToolbars
__experimentalCloneSanitizedBlock
__experimentalColorGradientControl
__experimentalColorGradientSettingsDropdown
__experimentalConvertBlockToStatic
__experimentalDateFormatPicker
__experimentalDefaultBlock
__experimentalDefaultControls
__experimentalDirectInsert
__experimentalDragComponent
__experimentalDropdownContentWrapper
__experimentalDuotone
__experimentalDuotoneControl
__experimentalEnableOffCanvasNavigationEditor
__experimentalExposeControlsToChildren
__experimentalFeatures
__experimentalFetchLinkSuggestions
__experimentalFetchReusableBlocks
__experimentalFetchRichUrlData
__experimentalFilterValue
__experimentalFirstVisibleItemClass
__experimentalFontAppearanceControl
__experimentalFontFamily
__experimentalFontFamilyControl
__experimentalFontStyle
__experimentalFontWeight
__experimentalGetAccessibleBlockLabel
__experimentalGetActiveBlockIdByBlockNames
__experimentalGetAllowedBlocks
__experimentalGetAllowedPatterns
__experimentalGetBlockAttributesNamesByRole
__experimentalGetBlockLabel
__experimentalGetBlockListSettingsForBlocks
__experimentalGetBorderClassesAndStyles
__experimentalGetColorClassesAndStyles
__experimentalGetDirectInsertBlock
__experimentalGetElementClassName
__experimentalGetGapCSSValue
__experimentalGetGlobalBlocksByName
__experimentalGetGradientClass
__experimentalGetGradientObjectByGradientValue
__experimentalGetLastBlockAttributeChanges
__experimentalGetMatchingVariation
__experimentalGetParsedPattern
__experimentalGetPatternTransformItems
__experimentalGetReusableBlockTitle
__experimentalGetSpacingClassesAndStyles
__experimentalGlobalStylesBaseStyles
__experimentalGroup
__experimentalHStack
__experimentalHandleURLSuggestions
__experimentalHasSplitBorders
__experimentalHeading__experimentalHideChildBlockControls
__experimentalHint
__experimentalImageEditor
__experimentalImageSizeControl
__experimentalImageURLInputUI
__experimentalInitialIndex
__experimentalInitialPosition
__experimentalInsertionIndex
__experimentalInspectorPopoverHeader
__experimentalIsDefinedBorder
__experimentalIsItemGroup
__experimentalIsQuick
__experimentalIsRenderedInSidebar
__experimentalItem
__experimentalItemGroup
__experimentalLabel
__experimentalLastVisibleItemClass
__experimentalLayout
__experimentalLayoutStyle
__experimentalLetterSpacing
__experimentalLetterSpacingControl
__experimentalLibrary
__experimentalLinkControl
__experimentalLinkControlSearchInput
__experimentalLinkControlSearchItem
__experimentalLinkControlSearchResults
__experimentalListView
__experimentalMinHeight
__experimentalNavigatorBackButton
__experimentalNavigatorButton
__experimentalNavigatorProvider
__experimentalNavigatorScreen
__experimentalNumberControl
__experimentalOnIndexChange
__experimentalOnlyMediaLibrary
__experimentalPadding
__experimentalPanelColorGradientSettings
__experimentalParentSelector
__experimentalParseQuantityAndUnitFromRawValue
__experimentalPreferPatternsOnRoot
__experimentalPreferredStyleVariations
__experimentalPreviewOptions
__experimentalPublishDateTimePicker
__experimentalRecursionProvider
__experimentalRenderControl
__experimentalRenderSuggestions
__experimentalResponsiveBlockControl
__experimentalReusableBlocks
__experimentalRichText
__experimentalRole
__experimentalSelectBlock
__experimentalSetIsInserterOpened
__experimentalSettings
__experimentalShareWithChildBlocks
__experimentalShouldInsertAtTheTop__experimentalShowInitialSuggestions
__experimentalSkipSerialization
__experimentalSlashInserter
__experimentalSpacer
__experimentalSpacingSizesControl
__experimentalStyleProvider
__experimentalText
__experimentalTextDecoration
__experimentalTextDecorationControl
__experimentalTextTransform
__experimentalTextTransformControl
__experimentalToggleGroupControl
__experimentalToggleGroupControlOption
__experimentalToggleGroupControlOptionIcon
__experimentalToolbar
__experimentalToolbarContext
__experimentalToolsPanel
__experimentalToolsPanelContext
__experimentalToolsPanelItem
__experimentalTransferDataType
__experimentalTreeGrid
__experimentalTreeGridCell
__experimentalTreeGridItem
__experimentalTreeGridRow
__experimentalTruncate
__experimentalUndo
__experimentalUnitControl
__experimentalUpdateSelection
__experimentalUseBlockOverlayActive
__experimentalUseBlockPreview
__experimentalUseBorderProps
__experimentalUseColorProps
__experimentalUseCustomSides
__experimentalUseCustomUnits
__experimentalUseDropZone
__experimentalUseFixedWindowList
__experimentalUseGradient
__experimentalUseHasRecursion
__experimentalUseMultipleOriginColorsAndGradients
__experimentalUseResizeCanvas
__experimentalUseSlot
__experimentalVStack
__experimentalVersion
__experimentalView

packages/block-library

__experimentalConvert
__experimentalDefault
__experimentalDiscussionSettings
__experimentalGetCoreBlocks
__experimentalGetDefaultTemplatePartAreas
__experimentalHideHeader
__experimentalIsEditingReusableBlock
__experimentalOnEnter
__experimentalRegisterExperimentalCoreBlocks
__experimentalSelector
__experimentalShowHowTo
__experimentalShowTooltip
__experimentalStyle
__experimentalTooltipProps

packages/blocks

__experimentalGetUnprocessedBlockTypes
__experimentalReapplyBlockTypeFilters
__experimentalRegisterBlockType
__experimentalSanitizeBlockAttributes

packages/components

__experimentalBorderControl
__experimentalConfirmDialog
__experimentalDimensionControl
__experimentalDivider
__experimentalElevation
__experimentalExpandOnFocus
__experimentalGrid
__experimentalInputControl
__experimentalInputControlPrefixWrapper
__experimentalInputControlSuffixWrapper
__experimentalInvalid
__experimentalIsEmptyBorder
__experimentalNavigation
__experimentalNavigationBackButton
__experimentalNavigationGroup
__experimentalNavigationItem
__experimentalNavigationMenu
__experimentalPaletteEdit
__experimentalRadio
__experimentalRadioGroup
__experimentalRenderItem
__experimentalScrollable
__experimentalSurface
__experimentalToggleGroupControlOptionBase
__experimentalUseDialog
__experimentalUseDragging
__experimentalUseFocusOutside
__experimentalUseNavigator
__experimentalValidateInput
__experimentalZStack

packages/compose

__experimentalWidthProvider

packages/core-data

__experimentalBatch
__experimentalFetchUrlData
__experimentalGetCurrentGlobalStylesId
__experimentalGetCurrentThemeBaseGlobalStyles
__experimentalGetCurrentThemeGlobalStylesVariations
__experimentalGetDirtyEntityRecords
__experimentalGetEntitiesBeingSaved
__experimentalGetEntityRecordNoResolver
__experimentalGetTemplateForLink
__experimentalNoFetch
__experimentalReceiveCurrentGlobalStylesId
__experimentalReceiveThemeBaseGlobalStyles
__experimentalReceiveThemeGlobalStyleVariations
__experimentalSaveSpecifiedEntityEdits
__experimentalUseEntityRecord
__experimentalUseEntityRecords
__experimentalUseResourcePermissions

packages/customize-widgets

__experimentalGetInsertionPoint

packages/date

__experimentalGetSettings

packages/e2e-test-utils

__experimentalActivatePlugin
__experimentalDeactivatePlugin
__experimentalRest

packages/edit-post

__experimentalFullscreenModeClose
__experimentalGetPreviewDeviceType
__experimentalMainDashboardButton
__experimentalSetPreviewDeviceType

packages/edit-site

__experimentalAdditionalBlockPatternCategories
__experimentalAdditionalBlockPatterns
__experimentalEnableColorRandomizer
__experimentalEnableGlobalStylesCustomCSS
__experimentalEnableZoomedOutView
__experimentalGetDefaultTemplateTypes
__experimentalGetTemplateInfo
__experimentalGlobalStylesCustomCSS

packages/editor

__experimentalCreatePageEntity
__experimentalGetDefaultTemplateType
__experimentalTearDownEditor
__experimentalUserCanCreatePages

packages/eslint-plugin

__experimentalFoo
__experimentalSafe
__experimentalUnsafe

packages/experiments

__experimentalFunction

packages/reusable-blocks

__experimentalConvertBlocksToReusable
__experimentalDeleteReusableBlock
__experimentalSetEditingReusableBlock

lib

__experimentalEnableListBlockV2
__experimentalEnableQuoteBlockV2

@ntsekouras ntsekouras added Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues. labels Jan 16, 2023
@fabiankaegy
Copy link
Member

I would like to understand what the procedure for __experimental APIs that were already introduced in previous versions of WordPress core and locking looks like. Will these API's be subject to locking or does the locking only apply to newly introduced __experimental APIs to prevent their usage?

From my perspective, the latter would be much preferred because several components have been experimental for a very long time and are so crucial that they have been used relatively widely. For example, the __experimentalLinkControl is getting used by quite a few third-party plugins just because it has been around for so long and I don't think it should get locked away at this point.

In order to prevent these kinds of things I'm 100% ob board with locking new introductions so they cannot get used before they are stable. But because weren't using this approach before there just are many components that are getting used relatively widely even when they shouldn't have been.

@ntsekouras
Copy link
Contributor Author

@fabiankaegy the locking will be for new experimental APIs that haven't been released in a stable WP version. The rest will be examined per use case about how to handle them.

@noisysocks
Copy link
Member

noisysocks commented Jan 17, 2023

Definitely agree we should use API in #46131 to lock() any new experimental APIs added between 6.1 and 6.2.

I'd personally be on board with then considering all pre-6.2 experimental APIs as "stable but discouraged". But not a strong opinion—I know it's a contentious issue 😅

Thinking that we should also reevaluate these posts. They don't seem to work—the list grows longer each release. Not sure what would work best. Perhaps assigning each experimental API an owner might work to remove any bystander effect. Or perhaps we don't need to audit experimental APIs at all.

@ntsekouras
Copy link
Contributor Author

Sorry for the massive ping, but I've updated the description to pinpoint the new APIs for 6.2. We need to check if we can stabilize any of them or lock them after merging this one - which is expected to land today probably.

@mirka
Copy link
Member

mirka commented Jan 17, 2023

__experimentalTheme @mirka

This component isn't publicly exported from the package yet so it should be fine. But I just realized that the readme isn't excluded from the public docs, so I'll get that fixed asap 🙊

@noisysocks
Copy link
Member

Thanks @ntsekouras. I edited the issue to bury the unimportant stuff in a <details>.

This is a much more manageable list. We should do it this way for future releases 🙂

@tellthemachines
Copy link
Contributor

Thanks for the ping @ntsekouras !

__experimentaluseLayoutClasses, __experimentaluseLayoutStyles

These are closely tied to the Layout block support which is also still an experimental API. I'm looking at stabilising it together with these smaller pieces soon, but I'm not sure it will be done in time for 6.2.

@getdave
Copy link
Contributor

getdave commented Jan 18, 2023

Noting that this PR landed #46131

@noisysocks
Copy link
Member

I've privatised this in #47229.

I've stabilised this in #47231.

@ntsekouras
Copy link
Contributor Author

ntsekouras commented Jan 18, 2023

These are closely tied to the Layout block support which is also still an experimental API. I'm looking at stabilising it together with these smaller pieces soon, but I'm not sure it will be done in time for 6.2.

@tellthemachines should we rename the new ones to lose the prefix then?

@tellthemachines
Copy link
Contributor

@ntsekouras not yet! There's still some work to do to make the layout API more usable before we stabilise it, and I think these functions shouldn't be stabilised before that as they might still change.

@talldan
Copy link
Contributor

talldan commented Jan 24, 2023

__experimentalHideBlockInterface, __experimentalIsBlockInterfaceHidden, __experimentalShowBlockInterface

I had a look at making these APIs private in #47375, but couldn't get the locking system working. Any advice on using the new API would be appreciated!

@talldan
Copy link
Contributor

talldan commented Jan 24, 2023

__experimentalClearBlockSelection

@joshuatf how has this been working out for you?

We need to make a call on whether to make it stable or make it harder to access for WordPress 6.2.

@andrewserong
Copy link
Contributor

#45875 @andrewserong

I've opened up a PR to explore stabilising this one in #47475 — happy for feedback, though, as I was a little on the fence as to which way to go, but wound up leaning toward stabilising + documenting since it hasn't needed any changes over the past couple of months.

@talldan
Copy link
Contributor

talldan commented Jan 27, 2023

@ntsekouras not yet! There's still some work to do to make the layout API more usable before we stabilise it, and I think these functions shouldn't be stabilised before that as they might still change.

Shouldn't these use the new locking system for experimental APIs, @tellthemachines?

If they ship with the __experimental prefix without being locked in 6.2, then there's a chance that will be considered a stable API and won't be removable.

@ciampo
Copy link
Contributor

ciampo commented Jan 27, 2023

@ciampo
Copy link
Contributor

ciampo commented Jan 27, 2023

Quick question — does any of the work related to this issue require a dev note? If so, should the need be assessed on a PR-per-PR basis, or should we have just one dev note the whole bunch of changes?

@ntsekouras
Copy link
Contributor Author

Quick question — does any of the work related to this issue require a dev note?

For locking new APIs that never made it into core, we don't need any dev note. For introducing new APIs we need dev notes.

@ciampo
Copy link
Contributor

ciampo commented Jan 27, 2023

When we stabilize an existing API and rename it by removing the __experimental prefix, would that be considered as an introduction of a new API?

@ntsekouras
Copy link
Contributor Author

When we stabilize an existing API and rename it by removing the __experimental prefix, would that be considered as an introduction of a new API?

That's a good question. I'd need some feedback for this one. --cc @priethor @youknowriad

@adamziel
Copy link
Contributor

Do we need a dev note about the lock()/unlock() api? I don’t think one makes sense - do you?

@priethor
Copy link
Contributor

That's a good question. I'd need some feedback for this one. --cc @priethor @youknowriad

They probably need a dev note. Even if there were a dev note for the __experimentalAPI (which, unless I'm mistaken or there was a strange scenario where an experimental API was publicly documented), it would be an API change in core that would need to be documented.

@noisysocks
Copy link
Member

The point of lock() and unlock() is that we want devs/extenders to not use it, right? In that sense I'd say no dev note is warranted.

@talldan
Copy link
Contributor

talldan commented Jan 31, 2023

There's a PR to lock the clearBlockSelection setting - #47591.

Decided to stabilize this one - #47627.

@tellthemachines
Copy link
Contributor

Shouldn't these https://github.com/WordPress/gutenberg/pull/46131s, @tellthemachines?

If they ship with the __experimental prefix without being locked in 6.2, then there's a chance that will be considered a stable API and won't be removable.

These are already in Core so I guess they technically are stable now 😅

@getdave
Copy link
Contributor

getdave commented Feb 1, 2023

I've made this getLastInsertedBlocksClientIds selector private #47638

@getdave
Copy link
Contributor

getdave commented Feb 1, 2023

__experimentalMetadata

I could do with some advice on what to do with #43986.

It introduces the metadata attribute as standard on blocks that opt in via __experimentalMetadata: true in block supports. It was designed for a PR I was working on but had to stop because I needed to focus on the Nav block list view work and thus the consuming PR never got merged. As a result it's not used in the codebase and thus has never been stress tested.

So how does one lock a block supports using the new APIs? Is it even possible?

Note there are also some utilities (not selectors) that access that setting such as hasBlockMetadataSupport but those aren't exported from the package so that's ok.

@Aljullu
Copy link
Contributor

Aljullu commented Feb 2, 2023

Howdy folks! In case it's useful, I wanted to share with you some Gutenberg __experimental features we are using in WooCommerce that have been reliable for us in the last months/years and we consider ready to be graduated. Of course, that's only based on our "consumer" point of view, so there might be other technical reasons not to graduate them, but we thought it might still be useful to share our experience.

@wordpress/block-editor functions

  • __experimentalUseGradient, __experimentalPanelColorGradientSettings, __experimentalHasMultipleOrigins and __experimentalIsRenderedInSidebar: used to support gradient overlays in the Featured Product and Featured Category blocks. They seem to have worked well for us these last months and we didn’t receive any issues.

Global styles properties

  • __experimentalFontStyle: used in a couple of our blocks in the WC Blocks feature plugin. It has worked well for us since it was introduced.
  • __experimentalFontWeight: used in several of our blocks in the feature plugin. It has worked well for us since it was introduced.
  • __experimentalBorder: used in several blocks. In WC core: Featured Product, Featured Category; only in the feature plugin: Product Button, Product Image and Product Sale Badge.
  • __experimentalFontFamily: we are using it in several blocks (Mini Cart, Customer account...). It has worked well for us so far.
  • __experimentalDefaultControls: not a critical one, but are using it in Featured Product and Featured Category blocks and never had any issues with it.

Components

FormTokenField props

  • __experimentalExpandOnFocus: we are using it in the Products block. It’s very handy when there are not many options available and we expect it to be easier for the user to select an option from the dropdown than having to write it.
  • __experimentalValidateInput: we are using it in conjunction to the previous one in the Products block to restrict the user to only introduce accepted values.

You can find a more in-depth audit here: https://github.com/woocommerce/woocommerce-blocks/discussions/8331.

@adamziel
Copy link
Contributor

adamziel commented Feb 3, 2023

So how does one lock a block supports using the new APIs? Is it even possible?

@getdave there's no systemic solution yet, but here's what you could do:

export function hasBlockMetadataSupport( blockType, feature = '' ) {
+	if ( ! blockType.startsWith('core/') ) {
+		return false;
+	}
	const support = getBlockSupport( blockType, '__experimentalMetadata' );
	return !! ( true === support || support?.[ feature ] );
}

adamziel added a commit that referenced this issue Feb 6, 2023
…wordpress/experiments (#47229)

## What?
Part of #47196. Uses `@wordpress/experiments` (#46131) to make `__experimentalShowSelectedHint` in `CustomSelectControl` private.

## Why?
We don't want to add any new experimental APIs to 6.2 as part of an effort to no longer expose experimental APIs in Core.

## How?
https://github.com/WordPress/gutenberg/blob/trunk/docs/contributors/code/coding-guidelines.md#experimental-react-component-properties

## Testing Instructions
1. Use a block theme with more than 5 font sizes or manually edit `theme.json` to contain more than 5 font sizes in `settings.typography.fontSizes`.
2. Open the site editor. Appearance → Editor → Edit.
3. Go to Styles → Typography → Headings.
4. Select a heading level.
5. Toggle off the custom font size picker.
6. You should see a hint alongside the selected font size preset.


Co-authored-by: Adam Zieliński <[email protected]>
@getdave
Copy link
Contributor

getdave commented Feb 6, 2023

__experimentalMetadata now being handled in #47791.

ntsekouras pushed a commit that referenced this issue Feb 9, 2023
…wordpress/experiments (#47229)

## What?
Part of #47196. Uses `@wordpress/experiments` (#46131) to make `__experimentalShowSelectedHint` in `CustomSelectControl` private.

## Why?
We don't want to add any new experimental APIs to 6.2 as part of an effort to no longer expose experimental APIs in Core.

## How?
https://github.com/WordPress/gutenberg/blob/trunk/docs/contributors/code/coding-guidelines.md#experimental-react-component-properties

## Testing Instructions
1. Use a block theme with more than 5 font sizes or manually edit `theme.json` to contain more than 5 font sizes in `settings.typography.fontSizes`.
2. Open the site editor. Appearance → Editor → Edit.
3. Go to Styles → Typography → Headings.
4. Select a heading level.
5. Toggle off the custom font size picker.
6. You should see a hint alongside the selected font size preset.


Co-authored-by: Adam Zieliński <[email protected]>
@ndiego ndiego moved this from 🗣️ In discussion, needs decision to 📥 Todo in WordPress 6.2 Editor Tasks Feb 9, 2023
@ntsekouras
Copy link
Contributor Author

Closing this issue as there are no more things to be done at this stage of 6.2 release cycle. Thanks to @adamziel 's API for private APIs and thanks to all the contributors that made private almost all of the new APIs that needed to be private, a lot of progress have been made to this front. 💯

Let's track the remaining work in this issue: #48743.

I'll also refer to @adamziel's comment, not to repeat it.

@github-project-automation github-project-automation bot moved this from 📥 Todo to ✅ Done in WordPress 6.2 Editor Tasks Mar 8, 2023
@adamziel
Copy link
Contributor

adamziel commented Mar 8, 2023

Great work everyone here, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Tracking Issue Tactical breakdown of efforts across the codebase and/or tied to Overview issues.
Projects
No open projects
Development

No branches or pull requests