-
Notifications
You must be signed in to change notification settings - Fork 0
Release/1.0.6 #20
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
Merged
Merged
Release/1.0.6 #20
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d468196
Merge pull request #9 from BeAPI/fix/icon-inserter
n-langle 930fb82
Merge pull request #10 from BeAPI/release/1.0.3
n-langle 937bd5d
Merge pull request #13 from BeAPI/release/1.0.4
firestar300 3599a0e
docs (README): adds initial README for the plugin
firestar300 f887c80
Merge branch 'release/1.0.4' into develop
firestar300 1b70019
Merge pull request #16 from BeAPI/release/1.0.5
firestar300 865716d
relase 1.0.6 : allow to use nested tabs block
MarieComet d8b4f35
fix jsdoc block and add missing useEffect depedencie
MarieComet 129ed7e
fix jsdoc block
MarieComet 88e9534
fix jsdoc block
MarieComet d50113f
fix jsdoc block again'
MarieComet 9d57a58
Merge pull request #18 from BeAPI/feat/tabs-in-tabs
MarieComet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "version": "1.0.5", | ||
| "version": "1.0.6", | ||
| "slug": "blockparty-tabs" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| /** | ||
|
Check failure on line 1 in src/blockparty-tabs/SyncTabsActive.js
|
||
| * Syncs the active tab state with the block selection in the editor. | ||
| * | ||
| * When this tab item (nav-item or panel-item) is the one selected or is the | ||
| * closest tab item to the current block selection, updates the parent | ||
| * blockparty/tabs block's tabsActive attribute to this item's index. | ||
| * | ||
| * This direct link (the clicked block updates its own tabs block) ensures | ||
| * correct behavior with nested tabs: only the tabs block that owns the | ||
| * selected tab is updated. | ||
| * | ||
| * @since 1.0.6 | ||
| * | ||
| * @param {Object} props Component props. | ||
| * @param {string} props.clientId This block's clientId (tabs-nav-item or tabs-panel-item). | ||
| * @return {null} Renders nothing. | ||
| */ | ||
| import { useEffect } from '@wordpress/element'; | ||
| import { useSelect, useDispatch } from '@wordpress/data'; | ||
|
|
||
| /** Block names that represent a single tab (nav link or panel). */ | ||
| const TAB_ITEM_NAMES = [ | ||
| 'blockparty/tabs-nav-item', | ||
| 'blockparty/tabs-panel-item', | ||
| ]; | ||
|
|
||
| export default function SyncTabsActive( { clientId } ) { | ||
| const { selectedBlockClientId, closestTabItemId, tabsBlockId, myIndex } = | ||
| useSelect( | ||
| ( select ) => { | ||
| const { | ||
| getBlockName, | ||
| getBlockIndex, | ||
| getSelectedBlockClientId, | ||
| getBlockParents, | ||
| getBlockRootClientId, | ||
| } = select( 'core/block-editor' ); | ||
| const selected = getSelectedBlockClientId(); | ||
| if ( ! selected ) { | ||
| return { | ||
| selectedBlockClientId: null, | ||
| closestTabItemId: null, | ||
| tabsBlockId: null, | ||
| myIndex: 0, | ||
| }; | ||
| } | ||
| // Find the tab item closest to the selection: the selected block if it | ||
| // is a tab item, otherwise the first tab item in the ancestor chain. | ||
| let closest = null; | ||
| if ( | ||
| TAB_ITEM_NAMES.indexOf( getBlockName( selected ) ) !== -1 | ||
| ) { | ||
| closest = selected; | ||
| } else { | ||
| const parents = getBlockParents( selected ); | ||
| for ( let i = 0; i < parents.length; i += 1 ) { | ||
| if ( | ||
| TAB_ITEM_NAMES.indexOf( | ||
| getBlockName( parents[ i ] ) | ||
| ) !== -1 | ||
| ) { | ||
| closest = parents[ i ]; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| // Parent chain: this block → tabs-nav or tabs-panels → blockparty/tabs. | ||
| const directParent = getBlockRootClientId( clientId ); | ||
| const tabsId = directParent | ||
| ? getBlockRootClientId( directParent ) | ||
| : null; | ||
| return { | ||
| selectedBlockClientId: selected, | ||
| closestTabItemId: closest, | ||
| tabsBlockId: tabsId, | ||
| myIndex: getBlockIndex( clientId ), | ||
| }; | ||
| }, | ||
| [ clientId ] | ||
| ); | ||
|
|
||
| const { updateBlockAttributes } = useDispatch( 'core/block-editor' ); | ||
|
|
||
| // When this block is the active tab (closest to selection or selected), sync tabsActive. | ||
| useEffect( () => { | ||
| if ( ! selectedBlockClientId || ! tabsBlockId ) { | ||
| return; | ||
| } | ||
| const isActiveTab = | ||
| closestTabItemId === clientId || selectedBlockClientId === clientId; | ||
| if ( ! isActiveTab ) { | ||
| return; | ||
| } | ||
| updateBlockAttributes( tabsBlockId, { tabsActive: myIndex } ); | ||
| }, [ | ||
| selectedBlockClientId, | ||
| closestTabItemId, | ||
| clientId, | ||
| tabsBlockId, | ||
| myIndex, | ||
| updateBlockAttributes, | ||
| ] ); | ||
|
|
||
| return null; | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.