Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
211 commits
Select commit Hold shift + click to select a range
4154e4c
Initial commit of tabs
sethrubenstein Dec 19, 2024
d0e886a
Yay, got the styles to work. I'll start back up tomorrow with some re…
sethrubenstein Dec 19, 2024
bf5d44f
Moving forward with Fabian's slotfill method for handling tab activat…
sethrubenstein Jan 6, 2025
df512d2
Huzzah, a default tab selection now working. I'm going to add redux s…
sethrubenstein Feb 19, 2025
abe0e90
Alright finally got the interactivity to register
sethrubenstein Feb 19, 2025
4f2a7f9
Removing the iAPI state role attribute artifact from the original PR
sethrubenstein Feb 20, 2025
1756bac
Core Data: Allow 'null' as raw attribute value (#69257)
Mamaduka Feb 20, 2025
0f7193c
Enhance 404 message styling (#69234)
Infinite-Null Feb 20, 2025
72ae0cb
Code cleanup and innerblocks config
sethrubenstein Feb 20, 2025
c300edf
Introduce `withSyncEvent` action wrapper utility and proxy `event` ob…
felixarntz Feb 20, 2025
afd4d37
Post Comments Count: Add Border Support (#68223)
shail-mehta Feb 21, 2025
563c891
docs: correction in plugin-sidebar-0.md (#69268)
kellymears Feb 21, 2025
b6bb01a
Allow :focus-visible pseudo-selector to be set in theme.json (#68521)
huubl Feb 21, 2025
7afecbf
Update javascript-in-the-block-editor.md - fix link (#62431)
juanmaguitar Feb 22, 2025
c3151e8
Dataviews: Fix alignment issue of "Title" column header (#68840)
im3dabasia Feb 23, 2025
cca7615
Video Block: Disable autoplay when video is not muted (#69232)
Rishit30G Feb 23, 2025
b06588e
Post formats: Make title and description human readable (#69275)
carolinan Feb 24, 2025
74a2ba4
TextControl: Fix text direction for URL and email fields in block edi…
im3dabasia Feb 24, 2025
d181ce4
Editor: Use a stable array ref as fallback value in 'BlockVisibility'…
Mamaduka Feb 24, 2025
77da6c2
Added php.net/date links (#69280)
shail-mehta Feb 25, 2025
3e6ddf9
Block support: Add server-side processing for ariaLabel (#69096)
t-hamano Feb 25, 2025
e532b74
Format Library: Prevent the text and color picker from overlapping (#…
shimotmk Feb 25, 2025
9a495f8
Test: Add e2e test for 404 page (#69272)
Infinite-Null Feb 25, 2025
db71531
Swap fullscreen mode snackbar notice message. (#69305)
afercia Feb 25, 2025
ac34493
Template Part block: Guard against `get_block_file_template` returnin…
ockham Feb 25, 2025
e757d1d
Update Changelog for 20.0.3
gutenbergplugin Feb 25, 2025
7a4b5aa
Url: Fix addQueryArgs and removeQueryArg on URLs with fragments (#69313)
davilera Feb 26, 2025
c283695
Editor: Persist user's 'Show Template' preference (#69286)
Mamaduka Feb 26, 2025
b532402
Post Navigation Link: Enable all non-interactive formats (#69325)
shimotmk Feb 26, 2025
fc40147
Bump the github-actions group across 2 directories with 3 updates (#6…
dependabot[bot] Feb 26, 2025
5c38661
Adding missing center alignment style for pullquote (#68121)
benazeer-ben Feb 27, 2025
0ec29dd
Document outline: Show heading blocks when template-lock is enabled (…
carolinan Feb 27, 2025
a02bf96
Fields: Avoid 'useSelect' warnings in the template component (#69344)
Mamaduka Feb 27, 2025
47fdb90
InputControl: Ensure consistent placeholder color (#69334)
SainathPoojary Feb 27, 2025
df6f07d
Close patterns modal on insertion and focus on inserted pattern (#68975)
yogeshbhutkar Feb 27, 2025
38610b0
Site Editor: Fix space on the left or right of the menu in mobile vie…
t-hamano Feb 27, 2025
50d457e
Format Library: Text-color popover width to fit sidebar (#68881)
shimotmk Feb 27, 2025
d8de061
FontSizePicker: Fix FontSizePicker Storybook control type and improve…
himanshupathak95 Feb 27, 2025
079996b
Editor: Revert bulk editing support for post actions (#69341)
Mamaduka Feb 27, 2025
18a4c0d
Remove unnecessary opacity override for Firefox placeholders (#69312)
himanshupathak95 Feb 27, 2025
5e7c286
Revert "Feature: Add `navigation.isLoading` state to core/router stor…
fabiankaegy Feb 28, 2025
0d5c310
Block Action: Implement cut functionality in block actions and settin…
yogeshbhutkar Feb 28, 2025
31fb13f
Bump plugin version to 20.4.0-rc.1
gutenbergplugin Feb 28, 2025
7e094b2
Update changelog files
gutenbergplugin Feb 28, 2025
0a6f557
chore(release): publish
gutenbergplugin Feb 28, 2025
c0f518b
Update Changelog for 20.4.0-rc.1
gutenbergplugin Feb 28, 2025
d2e36e3
Image block: unwrap img element in editor (#68666)
stokesman Feb 28, 2025
4e3b759
Remove trailing periods from Show or hide settings panel (#69356)
Infinite-Null Mar 1, 2025
31ee991
SpacerControls: default the height to `100px` if left unset (#68819)
yogeshbhutkar Mar 2, 2025
7c02f29
fix/social-links-disable-html-editing (#69374)
shimotmk Mar 2, 2025
2103d50
Remove non translatable additional info from font size picker visual …
afercia Mar 3, 2025
e093fef
Query Loop: Add 'menu_order' as sorting option (#68781)
kasparsd Mar 3, 2025
6ec211a
Site Editor: Fix template lookup preloading for non-draft pages (#69400)
Mamaduka Mar 4, 2025
5e9bb89
Site Title: Fix logic for 'aria-current' attribute (#68909)
bschneidewind Mar 5, 2025
d272c0a
Admin bar: Update the Edit Site link (#69271)
carolinan Mar 5, 2025
0daa060
Comment Template: Use fallback when there's an HTTP error (#69422)
Mamaduka Mar 5, 2025
8a3ef35
Testing: Skip failing post preview e2e tests (#69429)
Mamaduka Mar 5, 2025
1c1ffaf
Audio Block: Refactor setting panel to use ToolsPanel (#69324)
shimotmk Mar 5, 2025
418b293
Table Of Contents: Include headings exclusively within the `core/post…
yogeshbhutkar Mar 5, 2025
4e16551
DataView Actions Modal: Allow customizable `modal size` through props…
yogeshbhutkar Mar 5, 2025
42b68b0
Bump plugin version to 20.4.0
gutenbergplugin Mar 5, 2025
47cd256
Update Changelog for 20.4.0
gutenbergplugin Mar 5, 2025
98622bf
Latest Posts: Make Latest Posts block consistent with sticky posts di…
himanshupathak95 Mar 5, 2025
c6b1d9b
Fix: Show the author and author name examples in the Stylebook (#69436)
carolinan Mar 5, 2025
6dcf50f
Block Directory: Fix installations for 'template-locked' mode (#69394)
Mamaduka Mar 5, 2025
46e88a4
Added Missing Trailing (#69395)
shail-mehta Mar 5, 2025
96c45bd
Working on core/tabs deafult styling and innerblocks template/editing…
sethrubenstein Mar 5, 2025
76affa6
Working on new default fill and outline styles to match core/buttons
sethrubenstein Mar 5, 2025
af11c59
Editor: Make password protected input fields consistent (#69440)
afercia Mar 5, 2025
094ccdf
Trying to add border controls into parent block to control on innerbl…
sethrubenstein Mar 5, 2025
b8bf49d
Site Editor Sidebar: Fix header scrolling in mobile layout (#69413)
t-hamano Mar 6, 2025
55de75c
Testing: Restore post preview e2e tests (#69447)
t-hamano Mar 6, 2025
997934d
revert: default height to `100px` if left unset (#69450)
yogeshbhutkar Mar 6, 2025
7f943f5
Editor: Refactor the 'PostVisibility' component (#69451)
Mamaduka Mar 6, 2025
a793830
Button: Remove fixed width from small and compact buttons with icons …
himanshupathak95 Mar 6, 2025
877c45b
Site Editor: Make current theme and editor settings available to rout…
t-hamano Mar 6, 2025
e95970d
ARIA: Fix invalid `DropdownMenu` children structure (#69441)
im3dabasia Mar 6, 2025
b35550d
Editor: Optimize selector queries for Homepage and Posts Page actions…
Mamaduka Mar 6, 2025
e1fad76
Archives Block: Fix show label state (#69469)
shimotmk Mar 6, 2025
73ecc9d
Shadow, Duotone: Fix reset button style (#69471)
t-hamano Mar 6, 2025
df7d1cc
Update Changelog for 20.0.4
gutenbergplugin Mar 6, 2025
6d2a915
Update docs about wp-scripts build-blocks-manifest in relation to new…
felixarntz Mar 6, 2025
acb176e
Pre-publish panel: Do not show suggestions for tags and categories if…
carolinan Mar 6, 2025
e75326d
Updating some style concepts
sethrubenstein Mar 7, 2025
2141278
Fix error from popover scroll hook (#69479)
stokesman Mar 10, 2025
fc030b3
Editor: Preload template lookup (#69454)
Mamaduka Mar 10, 2025
a3c7d38
REST API: Add additional default template data fields for the active …
Mamaduka Mar 10, 2025
6683aff
Site Editor: Prevent access to the Design/Styles screen from classic …
t-hamano Mar 10, 2025
1d646ec
Query Total: Update the block color support settings (#69500)
HILAYTRIVEDI Mar 10, 2025
abf6d41
Document Outline: Disable selection for non-content headings (#69506)
Mamaduka Mar 10, 2025
66394c4
Classic themes: prevent access to parts of the Site Editor (#69473)
t-hamano Mar 10, 2025
90d34ff
Query Total: Prevent stricted type fatal errors on post per page. (#6…
cbravobernal Mar 10, 2025
2684096
Removed `color.__experimentalDuotone` from core blocks (#58241)
sabbir1991 Mar 10, 2025
8b88ada
Enhance create-block package to support blocks manifest and relevant …
felixarntz Mar 10, 2025
2ec6f6d
Editor: Fix 'slug' editing in 'template-locked' mode (#69516)
Mamaduka Mar 11, 2025
aaaf785
Classic theme site preview: Make all interactive elements unclickable…
t-hamano Mar 11, 2025
a97760c
Site Editor: Hide admin bar in classic theme site preview (#69514)
t-hamano Mar 11, 2025
6d261d4
Autocompleters: Change user slug color (#69003)
SainathPoojary Mar 11, 2025
9f77c96
Fix: Update invalid JSON Schema link in README.md (#69505)
Anuj-Rathore24 Mar 11, 2025
42caedd
Template UI mu-plugin: Run filter after the setup_theme action (#69542)
t-hamano Mar 12, 2025
444854d
Layout Support: Replace incremental IDs with hashes (#68210)
DAreRodz Mar 12, 2025
fc3f948
Site Editor: add period to Desgin description (#69537)
t-hamano Mar 12, 2025
d7dc363
Bump the github-actions group across 2 directories with 2 updates (#6…
dependabot[bot] Mar 12, 2025
d7d5aa3
ShadowsPanel: remove `Flex Wrapper` from `Subtitle` (#69541)
yogeshbhutkar Mar 12, 2025
57aa571
Plugin: Update hierarchical data compat directory (#69550)
Mamaduka Mar 12, 2025
14a989d
Block Editor: Resolve `MediaReplaceFlow` UI text inconsistency (#69546)
im3dabasia Mar 12, 2025
009d735
Docs/update reference to JS build setup 404 in scripts README, fix ab…
dontfeedthecode Mar 13, 2025
637ded5
Alignment note with Wordpress report 62426 (#69519)
SirLouen Mar 13, 2025
7ffab6c
Site Editor: show save panel in mobile layout (#69448)
t-hamano Mar 13, 2025
9352a29
Core Data: Update '__unstableBase' entity types (#69556)
Mamaduka Mar 13, 2025
8ec6b19
Editor: Use disabled state for 'Change template' menu item (#69558)
Mamaduka Mar 13, 2025
5c5b5d9
Button Block: Add draft page creation capability (#69368)
dhruvikpatel18 Mar 13, 2025
622f561
Editor: Optimize queries for 'useAllowSwitchingTemplates' hook (#69560)
Mamaduka Mar 13, 2025
e77dcf6
Bump plugin version to 20.5.0-rc.1
gutenbergplugin Mar 13, 2025
0bee5c7
Update Changelog for 20.5.0-rc.1
gutenbergplugin Mar 13, 2025
876dc56
Update changelog files
gutenbergplugin Mar 13, 2025
ae5aa63
chore(release): publish
gutenbergplugin Mar 13, 2025
1c698f8
Components: Fixed broken className test for `NumberControl` (#69540)
im3dabasia Mar 14, 2025
cf80203
Fix: Update viewportWidth of BlockPreview to better align with core b…
im3dabasia Mar 18, 2025
b47d966
Site Editor: Set `IFRAME_REQUEST` constant for classic theme site pre…
t-hamano Mar 18, 2025
9649c59
Update old URLs to new path-based URLs (#69585)
Infinite-Null Mar 18, 2025
f796b43
fix components-rangecontrol--docs (#69591)
shimotmk Mar 18, 2025
4695f61
BlockBreadcrumb: Wrap text node in span tag (#69605)
t-hamano Mar 18, 2025
9ed4aaa
Components: Fix autocomple UI flicker when deleting trigger prefix (#…
Mamaduka Mar 18, 2025
179c868
Bump the github-actions group across 2 directories with 1 update (#69…
dependabot[bot] Mar 18, 2025
6ed3c50
Reference `splitTask` from interactivity package in docs (#69602)
westonruter Mar 19, 2025
8e1d651
PostStatus: Prevent form submission from refreshing the page (#69526)
SainathPoojary Mar 19, 2025
9e3ff3f
Storybook: Update ToolbarItem and ToolbarDropdown exports (#69618)
Rishit30G Mar 19, 2025
abe0a0d
Fix flaky Typewriter e2e test (#69623)
Mamaduka Mar 19, 2025
dbec8d9
Add keyboard shortcut (`cmd(ctrl)+option(alt)+v`) to paste styles (#6…
yogeshbhutkar Mar 19, 2025
ee34069
Upgrade Playwright to v1.51.1 (#69622)
Mamaduka Mar 19, 2025
303a1e1
ComboboxControl: Replace `undefined` variable usage with `color-mix` …
yogeshbhutkar Mar 19, 2025
5cc4b71
Navigation Link: Don't check validity when block editing is disabled …
Mamaduka Mar 19, 2025
2a21c93
CustomSelectControl: Use dynamic fill color for `check` icon (#69626)
yogeshbhutkar Mar 19, 2025
743a876
Image: Don't subscribe to current post changes (#69630)
Mamaduka Mar 19, 2025
d83de25
Navigation Link: Optimize 'getBlockParentsByBlockName' selector call …
Mamaduka Mar 19, 2025
2a7a704
PatternsExplorerModal: Fix empty patterns in starter content category…
t-hamano Mar 20, 2025
1c05cce
Include blocks manifest build process in Webpack config to fix `creat…
felixarntz Mar 20, 2025
5e1dadf
Component: Extract `getNodeText` to its own file and add unit tests (…
im3dabasia Mar 20, 2025
330dafb
Bump plugin version to 20.5.0
gutenbergplugin Mar 20, 2025
c30b8c2
Update Changelog for 20.5.0
gutenbergplugin Mar 20, 2025
7129676
Site Title: Prevent saving and rendering a value made of only spaces …
himanshupathak95 Mar 20, 2025
3bdadeb
LinkControl: Fix visually Duplicative label and placeholder (#69620)
t-hamano Mar 21, 2025
d5f1275
scripts: fix broken changelog link (#69654)
t-hamano Mar 21, 2025
599d7b0
Fix shift+tab from post title (#69520)
stokesman Mar 21, 2025
956dfea
Image Block: omit max width observer element in galleries (#69601)
stokesman Mar 21, 2025
e9d5e0f
RSS Block: Display times using site display time (#69645).
SirLouen Mar 23, 2025
06690b0
Navigation Link: Improve performance by only requesting entities when…
Mamaduka Mar 24, 2025
221c956
PostCommentsForm: Fix submit button width regression (#69651)
im3dabasia Mar 24, 2025
8eb7055
chore: update browserslist and caniuse-lite to latest versions (#69669)
yogeshbhutkar Mar 24, 2025
feade05
Display Checkbox by default in dataviews (#67874)
karthick-murugan Mar 24, 2025
6278335
FontLibraryModal: Remove temporary margin-bottom override (#69674)
SainathPoojary Mar 24, 2025
f90f754
docs: Update code actions on save: true → explicit (#69670)
im3dabasia Mar 24, 2025
640172c
Site Editor: Make the text "Custom Styles" translatable (#69677)
t-hamano Mar 24, 2025
2382689
Query Total: Add interactivity.clientNavigation block support (#69661)
t-hamano Mar 24, 2025
2fa0eff
Components: Fix the AnglePickerControl example code. (#69673)
shimotmk Mar 24, 2025
e054cea
Editor: Revert new default rendering mode for Pages (#69680)
Mamaduka Mar 24, 2025
7fa13b8
PreviewDropdown: There's no need to unlock the 'getRenderingMode' sel…
Mamaduka Mar 24, 2025
571dc10
Format Library: Ensure inline image with updates persist after removi…
Sourav61 Mar 24, 2025
df219a4
Fix: Correct 'Displaying 1 – 0 of 0' issue when no results are found …
Sourav61 Mar 25, 2025
bb9028d
Testing: Fix e2e and performance tests (#69690)
Mamaduka Mar 25, 2025
e21e46a
Editor: Clarify icon prop behavior in README (#69672)
Infinite-Null Mar 25, 2025
62e5d7a
Update list of Gutenberg version and WordPress versions (#69700)
bph Mar 25, 2025
3715ede
Update `NumberControl` stepping to match HTML number input stepping (…
stokesman Mar 26, 2025
b28716a
Categories: Use optional chaining for taxonomy properties to prevent …
Mayank-Tripathi32 Mar 26, 2025
1a2b386
Global Styles: Prevent Unwanted ItemGroup List Rendering in Border Pa…
im3dabasia Mar 26, 2025
9ebe4c6
Testing: Refactor 'Template hierarchy' e2e tests (#69692)
Mamaduka Mar 26, 2025
c99c02b
Embed: Only call `setAttributes()` in `useEffect` when attributes cha…
chrisbellboy Mar 26, 2025
57e7bbc
BlockPatternsExplorer: Hide scrollbar from sidebar if not scrollable …
t-hamano Mar 26, 2025
2014003
RSS Block: Add option to open links in new tab/window and control rel…
dhruvikpatel18 Mar 26, 2025
1a7b835
Plugin: Update Gutenberg demo content to remove underlying migrations…
yogeshbhutkar Mar 26, 2025
87b3aa3
fix: render `create-new-template-modal` over `post-template-panel` (#…
yogeshbhutkar Mar 27, 2025
c47c3bc
Missing comma in dataview docs. (#69721)
StevenDufresne Mar 27, 2025
86f96e0
e2e: fix taxomomies test (#69723)
t-hamano Mar 27, 2025
20fb420
Post Template Panel: Preserve parent modal when closing template crea…
yogeshbhutkar Mar 27, 2025
63c711d
Navigation Block: Add transparency slider for submenu background (#69…
dhruvikpatel18 Mar 27, 2025
bdb1679
Featured Image: Prevent default action on image click to fix linking …
Mayank-Tripathi32 Mar 27, 2025
1291719
Feature: Adding support for more granular controls over the ToC block…
gmovr Mar 27, 2025
7887d9c
Bump plugin version to 20.6.0-rc.1
gutenbergplugin Mar 27, 2025
a579f73
Update Changelog for 20.6.0-rc.1
gutenbergplugin Mar 27, 2025
be42968
Update changelog files
gutenbergplugin Mar 27, 2025
20c77f5
chore(release): publish
gutenbergplugin Mar 27, 2025
50be538
Details: Enable all non-interactive formats (#68741)
im3dabasia Mar 28, 2025
ae48c49
Fix: save custom template with non-latin slug (#69732)
t-hamano Mar 28, 2025
95d1d1b
Format Library: Add a feature to set alpha value to Highlight (#67525)
shimotmk Mar 28, 2025
06fb317
ToC: Fix related block attribute persistence (#69734)
Mamaduka Mar 28, 2025
365567d
Button: Update hover styles to account for pressed state for `tertiar…
yogeshbhutkar Mar 28, 2025
cd69417
Block Editor: Remove truncation from media tab preview tooltips (#69741)
Sukhendu2002 Mar 28, 2025
4ee2d92
Tag Cloud: Remove unnecessary full-width padding (#69725)
dhruvikpatel18 Mar 28, 2025
d8545b2
Global Styles: Fix incorrect usage of ItemGroup in the Background ima…
im3dabasia Mar 28, 2025
0fc6ab7
Continuing with border/radius styling for tabs before moving on to ke…
sethrubenstein Mar 28, 2025
c5ab4d2
Kinda annoying, I think we should probably ignore .vscode/settings.js…
sethrubenstein Mar 28, 2025
db7a9ba
Moving away from border and radius control. Cool that I was able to a…
sethrubenstein Mar 28, 2025
92f3543
Initial commit of tabs
sethrubenstein Dec 19, 2024
b12fa3a
Yay, got the styles to work. I'll start back up tomorrow with some re…
sethrubenstein Dec 19, 2024
abb6783
Moving forward with Fabian's slotfill method for handling tab activat…
sethrubenstein Jan 6, 2025
cece124
Huzzah, a default tab selection now working. I'm going to add redux s…
sethrubenstein Feb 19, 2025
f50e7d8
Alright finally got the interactivity to register
sethrubenstein Feb 19, 2025
05522d2
Removing the iAPI state role attribute artifact from the original PR
sethrubenstein Feb 20, 2025
81a5172
Code cleanup and innerblocks config
sethrubenstein Feb 20, 2025
e2339c9
Working on core/tabs deafult styling and innerblocks template/editing…
sethrubenstein Mar 5, 2025
9bd6169
Working on new default fill and outline styles to match core/buttons
sethrubenstein Mar 5, 2025
4117c66
Trying to add border controls into parent block to control on innerbl…
sethrubenstein Mar 5, 2025
8760765
Updating some style concepts
sethrubenstein Mar 7, 2025
d72c11a
Continuing with border/radius styling for tabs before moving on to ke…
sethrubenstein Mar 28, 2025
06d9148
Kinda annoying, I think we should probably ignore .vscode/settings.js…
sethrubenstein Mar 28, 2025
db9258b
Moving away from border and radius control. Cool that I was able to a…
sethrubenstein Mar 28, 2025
365cf06
Merge branch 'new-block/tabs' of github.com:pewresearch/gutenberg int…
sethrubenstein Mar 28, 2025
191636d
Updating branch to latest Gutenberg trunk and updating iAPI directive…
sethrubenstein Mar 28, 2025
2e6e041
Center tabs list inserter
sethrubenstein Mar 28, 2025
9e55824
Adding fallback for border line when no active color defined
sethrubenstein Mar 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Code cleanup and innerblocks config
  • Loading branch information
sethrubenstein committed Feb 20, 2025
commit 72ae0cb06f96155adc5a1a1e676b69aaa2991364
113 changes: 66 additions & 47 deletions packages/block-library/src/tab/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
RichText,
} from '@wordpress/block-editor';
import { useSelect, useDispatch } from '@wordpress/data';
import { Fragment, useMemo } from '@wordpress/element';
import { PanelBody, TextControl } from '@wordpress/components';
import { Fragment, useMemo, useRef } from '@wordpress/element';
import { PanelBody, TextControl, ToggleControl } from '@wordpress/components';
import { cleanForSlug } from '@wordpress/url';

/**
Expand Down Expand Up @@ -49,7 +49,8 @@ export default function Edit( {
setAttributes,
} ) {
const { anchor, label, slug } = attributes;
const { selectBlock } = useDispatch( blockEditorStore );
const { selectBlock, updateBlockAttributes } =
useDispatch( blockEditorStore );

const {
blockIndex,
Expand All @@ -58,43 +59,54 @@ export default function Edit( {
tabsHasSelectedBlock,
tabsClientId,
forceDisplay,
isFirstTab,
isTabsClientSelected,
previousTabClientId,
nextTabClientId,
isDefaultTab,
} = useSelect(
( select ) => {
const rootClientId =
select( blockEditorStore ).getBlockRootClientId( clientId );
const _isFirstTab =
select( blockEditorStore ).getBlockIndex( clientId ) === 0;
const _isTabsClientSelected =
select( blockEditorStore ).isBlockSelected( rootClientId );
// Check if any of the rootClientId blocks are selected...
const hasTabSelected = select(
blockEditorStore
).hasSelectedInnerBlock( rootClientId, true );
const {
getBlockRootClientId,
getBlockIndex,
getBlockOrder,
getPreviousBlockClientId,
getNextBlockClientId,
isBlockSelected,
hasSelectedInnerBlock,
getBlockAttributes,
} = select( blockEditorStore );

// Get data from core/tabs.
const rootClientId = getBlockRootClientId( clientId );
const hasTabSelected = hasSelectedInnerBlock( rootClientId, true );
const rootAttributes = getBlockAttributes( rootClientId );
const { activeTabIndex } = rootAttributes;
const _isTabsClientSelected = isBlockSelected( rootClientId );

// Get data about this instance of core/tab.
const _blockIndex = getBlockIndex( clientId );
const _isDefaultTab = activeTabIndex === _blockIndex;
const _hasChildBlocks = getBlockOrder( clientId ).length > 0;
const _hasInnerBlocksSelected = hasSelectedInnerBlock(
clientId,
true
);

// Get data about the previous and next tabs.
const _previousTabClientId = getPreviousBlockClientId( clientId );
const _nextTabClientId = getNextBlockClientId( clientId );

return {
blockIndex:
select( blockEditorStore ).getBlockIndex( clientId ),
hasChildBlocks:
select( blockEditorStore ).getBlockOrder( clientId )
.length > 0,
hasInnerBlocksSelected: select(
blockEditorStore
).hasSelectedInnerBlock( clientId, true ),
blockIndex: _blockIndex,
hasChildBlocks: _hasChildBlocks,
hasInnerBlocksSelected: _hasInnerBlocksSelected,
tabsClientId: rootClientId,
forceDisplay: _isFirstTab && _isTabsClientSelected,
forceDisplay: _isDefaultTab && _isTabsClientSelected,
tabsHasSelectedBlock: hasTabSelected,
isFirstTab: _isFirstTab,
isTabsClientSelected: _isTabsClientSelected,
previousTabClientId:
select( blockEditorStore ).getPreviousBlockClientId(
clientId
),
nextTabClientId:
select( blockEditorStore ).getNextBlockClientId( clientId ),
previousTabClientId: _previousTabClientId,
nextTabClientId: _nextTabClientId,
isDefaultTab: _isDefaultTab,
};
},
[ clientId ]
Expand All @@ -108,7 +120,7 @@ export default function Edit( {
return true;
}
if (
isFirstTab &&
isDefaultTab &&
! isTabsClientSelected &&
! isSelected &&
! tabsHasSelectedBlock
Expand All @@ -120,7 +132,7 @@ export default function Edit( {
isSelected,
hasInnerBlocksSelected,
forceDisplay,
isFirstTab,
isDefaultTab,
isTabsClientSelected,
tabsHasSelectedBlock,
] );
Expand All @@ -133,11 +145,20 @@ export default function Edit( {
hidden: ! isSelectedTab,
} );

const innerBlocksRef = useRef( null );

const innerBlocksProps = useInnerBlocksProps(
{
'aria-labelledby': tabLabelId,
id: tabPanelId,
role: 'tabpanel',
ref: innerBlocksRef,
template: [
[
'core/paragraph',
],
],
tabIndex: 0,
},
{
renderAppender: hasChildBlocks
Expand All @@ -159,6 +180,19 @@ export default function Edit( {
__next40pxDefaultSize
__nextHasNoMarginBottom
/>
<ToggleControl
label="Is Default"
checked={ isDefaultTab }
onChange={ ( value ) => {
updateBlockAttributes( tabsClientId, {
activeTabIndex: value ? blockIndex : 0,
} );
} }
help={ __(
'If true, this tab will be selected when the page loads.'
) }
__nextHasNoMarginBottom
/>
</PanelBody>
</InspectorControls>

Expand All @@ -170,21 +204,6 @@ export default function Edit( {
aria-selected={ isSelectedTab }
className="tabs__tab-label"
id={ tabLabelId }
onKeyDown={ ( event ) => {
// Playing around with keyboard navigation. Will settle on the best approach next.
switch ( event.key ) {
case 'ArrowLeft':
case 'ArrowUp':
event.preventDefault();
selectBlock( previousTabClientId );
break;
case 'ArrowRight':
case 'ArrowDown':
event.preventDefault();
selectBlock( nextTabClientId );
break;
}
} }
role="tab"
tabIndex="0"
>
Expand Down
19 changes: 4 additions & 15 deletions packages/block-library/src/tabs/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
InnerBlocks,
} from '@wordpress/block-editor';
import { Fragment } from '@wordpress/element';
import { useDispatch } from '@wordpress/data';

/**
* Internal dependencies
Expand All @@ -19,8 +18,8 @@ import useColorSupports from './use-color-supports';
import { TabFill } from '../tab/slotfill';

const TABS_TEMPLATE = [
[ 'core/tab', { label: 'Tab 1' } ],
[ 'core/tab', { label: 'Tab 2' } ],
[ 'core/tab', { label: 'Tab 1', slug: 'tab-1' }, [ [ 'core/paragraph' ] ] ],
[ 'core/tab', { label: 'Tab 2', slug: 'tab-2' }, [ [ 'core/paragraph' ] ] ],
];

function Edit( {
Expand Down Expand Up @@ -90,17 +89,10 @@ function Edit( {
clientId,
orientation,
template: TABS_TEMPLATE,
renderAppender: false, // We handle this element ourselves.
}
);

const { insertBlock } = useDispatch( blockEditorStore );

const appendTabItem = () => {
insertBlock( 'core/tab', {
label: 'New Tab',
} );
};

return (
<Fragment>
<Controls
Expand All @@ -126,10 +118,7 @@ function Edit( {
{ innerBlockProps.children }
<TabFill tabsClientId={ clientId }>
<li className="tab-item wp-block-tabs__tab-item tab-item__inserter">
<InnerBlocks.ButtonBlockAppender
icon="plus"
onClick={ appendTabItem }
/>
<InnerBlocks.ButtonBlockAppender />
</li>
</TabFill>
</div>
Expand Down
11 changes: 9 additions & 2 deletions packages/block-library/src/tabs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function render_block_core_tabs( $attributes, $content, $block ) {

$styles = block_core_tabs_generate_color_variables( $attributes );

$url_encoded_active_tab_index = get_query_var( 'activeTabIndex', 0 );
$url_encoded_active_tab_index = get_query_var( 'activeTabIndex', false );
// Validate base64 string and safely decode
$decoded_tab_index = '';
if (is_string($url_encoded_active_tab_index) && !empty($url_encoded_active_tab_index)) {
Expand All @@ -62,7 +62,7 @@ function render_block_core_tabs( $attributes, $content, $block ) {
$decoded_tab_index = ($decoded_tab_index !== false) ? $decoded_tab_index : '';
}
// Only try to match if we have a valid decoded string
$active_tab_index = 0;
$active_tab_index = $attributes['activeTabIndex'];
if (!empty($decoded_tab_index)) {
preg_match('/__(\d+)$/', $decoded_tab_index, $matches);
$active_tab_index = isset($matches[1]) ? (int) $matches[1] : 0;
Expand Down Expand Up @@ -109,6 +109,13 @@ function ( $tab ) {
while ( $p->next_tag( array( 'class_name' => 'wp-block-tab' ) ) ) {
$p->set_attribute( 'role', 'tabpanel' );
$p->set_attribute( 'data-tab-index', $tab_index );
$p->set_attribute( 'data-wp-interactive', 'core/tabs' );
$p->set_attribute( 'data-wp-context', wp_json_encode(
array(
'isActiveTab' => $tab_index === $active_tab_index,
'tabIndex' => $tab_index,
)
) );
$p->set_attribute( 'data-wp-bind--hidden', '!state.isActiveTab' );
$p->set_attribute( 'data-wp-bind--tabindex', 'state.tabindexPanelAttribute' );
$tab_index++;
Expand Down
6 changes: 2 additions & 4 deletions packages/block-library/src/tabs/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* @param int $index The index of the tab.
* @return WP_Block_Parser_Block The tab block
*/
function generate_tab( $label, $content, $index = 0 ) {
function generate_tab( $label, $content ) {

Check failure on line 14 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Missing @SInCE tag for the "generate_tab()" function.

Check failure on line 14 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

The function name 'generate_tab()' is invalid. In this file, PHP function names must either match one of the allowed prefixes exactly or begin with one of them, followed by an underscore. The allowed prefixes are: 'block_core_tabs', 'render_block_core_tabs', 'register_block_core_tabs'.
$parsed_content = is_array( $content ) ? $content : parse_blocks( $content );
$inner_html_start = wp_sprintf(
'<section id="%s" class="wp-block-prc-block-tab">',
Expand All @@ -20,12 +20,11 @@
$inner_html_end = '</section>';
$inner_html = $inner_html_start . $inner_html_end;
$nulls = count( $parsed_content );
$tab_block = new WP_Block_Parser_Block(

Check warning on line 23 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Equals sign not aligned with surrounding assignments; expected 8 spaces but found 1 space
'core/tab',
array(
'label' => $label,

Check warning on line 26 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Array double arrow not aligned correctly; expected 1 space(s) between "'label'" and double arrow, but found 4.
'slug' => sanitize_title( $label ),

Check warning on line 27 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Array double arrow not aligned correctly; expected 2 space(s) between "'slug'" and double arrow, but found 5.
'tabIndex' => $index,
),
$parsed_content,
$inner_html,
Expand All @@ -44,19 +43,18 @@
* @param array $tabs An array of tabs to create.
* @return array An array of blocks representing the tabs
*/
function create_tabs( $tabs = array(), $attributes = array() ) {

Check failure on line 46 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Missing @SInCE tag for the "create_tabs()" function.

Check failure on line 46 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

The function name 'create_tabs()' is invalid. In this file, PHP function names must either match one of the allowed prefixes exactly or begin with one of them, followed by an underscore. The allowed prefixes are: 'block_core_tabs', 'render_block_core_tabs', 'register_block_core_tabs'.
$inner_html = '';

Check warning on line 47 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Unused variable $inner_html.
$inner_content = array();
$inner_blocks = array();
$tab_index = 0;

Check warning on line 50 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Unused variable $tab_index.

foreach ( $tabs as $tab ) {
$new_tab = generate_tab( $tab['label'], $tab['content'], $tab_index );
$new_tab = generate_tab( $tab['label'], $tab['content'] );

Check warning on line 53 in packages/block-library/src/tabs/util.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space
$inner_html .= $new_tab->innerHTML; // phpcs:ignore WordPress.NamingConventions.ValidVariableName
$new_tab = (array) $new_tab;
$inner_blocks[] = $new_tab;
$inner_content[] = null;
++$tab_index;
}

$tabs = new WP_Block_Parser_Block(
Expand Down
Loading