Skip to content

Commit

Permalink
making a dedicated scrollspy unique id that will help differentiate d…
Browse files Browse the repository at this point in the history
…ifferent instances of the same nav for scrollspy.
  • Loading branch information
mark-c-woodard committed Dec 16, 2024
1 parent 975fdec commit 5f36e66
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion includes/assets/js/kb-navigation-block.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 11 additions & 7 deletions includes/blocks/class-kadence-blocks-navigation-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,15 +408,19 @@ public function build_html( $attributes, $unique_id, $content, $block_instance )

$name = ! empty( $attributes['name'] ) ? $attributes['name'] : '';

$wrapper_attributes = get_block_wrapper_attributes(
array(
'class' => implode( ' ', $wrapper_classes ),
'aria-label' => $name,
'data-scroll-spy' => $nav_attributes['enableScrollSpy'],
'data-scroll-spy-offset' => $nav_attributes['scrollSpyOffsetManual'] ? $nav_attributes['scrollSpyOffset'] : false,
)
$wrapper_attribute_items = array(
'class' => implode( ' ', $wrapper_classes ),
'aria-label' => $name,
'data-scroll-spy' => $nav_attributes['enableScrollSpy'],
);

if ( $nav_attributes['enableScrollSpy'] ) {
$wrapper_attribute_items['data-scroll-spy-offset'] = $nav_attributes['scrollSpyOffsetManual'] ? $nav_attributes['scrollSpyOffset'] : false;
$wrapper_attribute_items['data-scroll-spy-id'] = uniqid();
}

$wrapper_attributes = get_block_wrapper_attributes( $wrapper_attribute_items );

// Navigation Attributes.
$navigation_classes = array();

Expand Down
4 changes: 2 additions & 2 deletions kadence-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Advanced Page Building Blocks for Gutenberg. Create custom column layouts, backgrounds, dual buttons, icons etc.
* Author: Kadence WP
* Author URI: https://www.kadencewp.com
* Version: 3.4.1
* Version: 3.4.2
* Requires PHP: 7.4
* Text Domain: kadence-blocks
* License: GPL2+
Expand All @@ -20,7 +20,7 @@
}
define( 'KADENCE_BLOCKS_PATH', realpath( plugin_dir_path( __FILE__ ) ) . DIRECTORY_SEPARATOR );
define( 'KADENCE_BLOCKS_URL', plugin_dir_url( __FILE__ ) );
define( 'KADENCE_BLOCKS_VERSION', '3.4.1' );
define( 'KADENCE_BLOCKS_VERSION', '3.4.2' );

require_once plugin_dir_path( __FILE__ ) . 'vendor/vendor-prefixed/autoload.php';
require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: gutenberg, blocks, page builder, editor, gutenberg blocks
Donate link: https://www.kadencewp.com/about-us/
Requires at least: 6.4
Tested up to: 6.7.1
Stable tag: 3.4.1
Stable tag: 3.4.2
Requires PHP: 7.4
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -174,6 +174,10 @@ Please report security bugs found in the Kadence Blocks plugin's source code thr

== Changelog ==

= 3.4.2 =
Release Date: tba
* Add: Features for activating nav links with hash anchor links on the page

= 3.4.1 =
Release Date: December 12th 2024
* Update: allowing splide slider options to be translated.
Expand Down
3 changes: 2 additions & 1 deletion src/assets/js/kb-navigation-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,8 +459,9 @@
//here, we'll assume we're in a header block and look for the containing row height
var offsetTarget = scrollSpyTarget.closest('.wp-block-kadence-header-row');
}
const scrollSpyId = scrollSpyTarget.dataset?.scrollSpyId;
// Initialize Gumshoe
new Gumshoe('.' + scrollSpyTarget.classList[0] + ' .kb-navigation a', {
new Gumshoe('.wp-block-kadence-navigation[data-scroll-spy-id="' + scrollSpyId + '"] .kb-navigation a', {
nested: true,
nestedClass: 'current-menu-ancestor',
navClass: 'current-menu-item',
Expand Down

0 comments on commit 5f36e66

Please sign in to comment.