Skip to content

Commit

Permalink
Fix a regression with anchors not working when target not found, rele…
Browse files Browse the repository at this point in the history
…ase 6.4.2
  • Loading branch information
ronilaukkarinen committed Jan 10, 2024
1 parent 8246662 commit ebb0679
Show file tree
Hide file tree
Showing 14 changed files with 428 additions and 283 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 9.3.6rc: 2024-01-10
### 9.3.6: 2024-01-10

* Fix the permission issue with self-updater
* Fix ACF element colors in Gutenberg editor
Expand All @@ -20,6 +20,8 @@
* Merge pull request #211 from digitoimistodude/dependabot/npm_and_yarn/axios-and-browser-sync--removed
* Remove deprecated number-leading-zero rule
* Add reset for img
* Fix a regression with anchors not working when target not found, use in all hashs not just with js-trigger class
* Bump WordPress to 6.4.2

### 9.3.5: 2023-09-12

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ Starting from v2.6.0 WooCommerce support comes with [Air helper](https://github.

* PHP >= 7.4
* Requires at least: WordPress 4.7.1
* Tested up to WordPress 6.3.1
* Tested up to WordPress 6.4.2

### Recommendations for development

Expand Down
4 changes: 2 additions & 2 deletions bin/tasks/additions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ chmod 777 ${PROJECT_PATH}/media

echo "${YELLOW}Generating default README.md...${TXTRESET}"

NEWEST_AIR_VERSION="9.3.5"
NEWEST_WORDPRESS_VERSION="6.3.1"
NEWEST_AIR_VERSION="9.3.6"
NEWEST_WORDPRESS_VERSION="6.4.2"
NEWEST_PHP_VERSION="7.4"
CURRENT_DATE=$(LC_TIME=en_US date '+%d %b %Y' |tr ' ' '_');
echo "# ${PROJECT_NAME}
Expand Down
4 changes: 2 additions & 2 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* @Date: 2019-10-15 12:30:02
* @Last Modified by: Roni Laukkarinen
* @Last Modified time: 2023-09-12 12:20:49
* @Last Modified time: 2024-01-10 18:54:48
*
* @package air-light
*/
Expand All @@ -17,7 +17,7 @@
/**
* The current version of the theme.
*/
define( 'AIR_LIGHT_VERSION', '9.3.5' );
define( 'AIR_LIGHT_VERSION', '9.3.6' );

// We need to have some defaults as comments or empties so let's allow this:
// phpcs:disable Squiz.Commenting.InlineComment.SpacingBefore, WordPress.Arrays.ArrayDeclarationSpacing.SpaceInEmptyArray
Expand Down
6 changes: 3 additions & 3 deletions header.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*
* @Author: Roni Laukkarinen
* @Date: 2020-05-11 13:17:32
* @Last Modified by: Tuomas Marttila
* @Last Modified time: 2023-02-27 10:46:23
* @Last Modified by: Roni Laukkarinen
* @Last Modified time: 2024-01-10 18:53:14
*
* @package air-light
*/
Expand All @@ -28,7 +28,7 @@
</head>

<body <?php body_class( 'no-js' ); ?>>
<a class="skip-link screen-reader-text js-trigger" href="#content"><?php echo esc_html( get_default_localization( 'Skip to content' ) ); ?></a>
<a class="skip-link screen-reader-text" href="#content"><?php echo esc_html( get_default_localization( 'Skip to content' ) ); ?></a>

<?php wp_body_open(); ?>
<div id="page" class="site">
Expand Down
5 changes: 0 additions & 5 deletions inc/includes/nav-walker.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,6 @@ public function start_el( &$output, $item, $depth = 0, $args = null, $id = 0 ) {
}
}

// If has hash in the beginning of href attribute, add class js-trigger
if ( '#' === substr( $atts['href'], 0, 1 ) ) {
$atts['class'] .= ' js-trigger';
}

// Aria current
$atts['aria-current'] = $item->current ? 'page' : '';

Expand Down
18 changes: 4 additions & 14 deletions js/dev/front-end.js

Large diffs are not rendered by default.

618 changes: 386 additions & 232 deletions js/dev/legacy.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/prod/front-end.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/prod/legacy.js

Large diffs are not rendered by default.

34 changes: 19 additions & 15 deletions js/src/modules/anchors.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* @Author: Roni Laukkarinen
* @Date: 2022-05-07 12:20:13
* @Last Modified by: Roni Laukkarinen
* @Last Modified time: 2023-05-18 17:38:05
* @Last Modified time: 2024-01-10 18:53:09
*/
import MoveTo from 'moveto';

const initAnchors = () => {
// General anchors used in links with class "js-trigger"
const easeFunctions = {
easeInQuad(t, b, c, d) { t /= d; return c * t * t + b; },
easeOutQuad(t, b, c, d) {
Expand All @@ -21,29 +20,34 @@ const initAnchors = () => {
easeFunctions,
);

const triggers = document.getElementsByClassName('js-trigger');
// Get all links that have only the hash as href and is not back to top link
const triggers = document.querySelectorAll('a[href*="#"]:not([href="#"]):not(#top)');

// eslint-disable-next-line no-plusplus
for (let i = 0; i < triggers.length; i++) {
// If target doesn't exist, bail
if (!document.getElementById(triggers[i].hash.substring(1))) {
return;
}

// Move to target smoothly
moveTo.registerTrigger(triggers[i]);
const target = document.getElementById(triggers[i].hash.substring(1));

// Focus to target
triggers[i].addEventListener('click', (event) => {
// If the trigger is nav-link, close nav
if (triggers[i].classList.contains('nav-link')) {
document.body.classList.remove('js-nav-active');
}

triggers[i].addEventListener('click', () => {
// If the trigger is nav-link, close nav
if (triggers[i].classList.contains('nav-link')) {
document.body.classList.remove('js-nav-active');
}

event.preventDefault();
const target = document.getElementById(triggers[i].hash.substring(1));
target.setAttribute('tabindex', '-1');
target.focus();
window.history.pushState('', '', triggers[i].hash);
// Focus to target
if (target) {
// Needs delay for smooth moveTo scroll
setTimeout(() => {
target.setAttribute('tabindex', '-1');
target.focus();
}, 500);
}
});
}
};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "air-light",
"version": "9.3.5",
"version": "9.3.6",
"description": "A minimalist WordPress starter theme.",
"author": "Digitoimisto Dude Oy ([email protected])",
"devDependencies": {
Expand Down Expand Up @@ -72,4 +72,4 @@
"moveto": "^1.8.2",
"reframe.js": "^4.0.0"
}
}
}
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Contributors: Digitoimisto Dude Oy
Tags: one-column, accessibility-ready, translation-ready

Requires at least: 5.0
Tested up to: 6.3.1
Tested up to: 6.4.2
Stable tag: 9.3.5
License: MIT License
License URI: https://opensource.org/licenses/MIT
Expand Down
6 changes: 3 additions & 3 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Theme URI: https://github.com/digitoimistodude/air-light
Author: Digitoimisto Dude Oy
Author URI: https://www.dude.fi
Description: Hi. I'm a starter theme called <code>Air-light</code>, or <em>air</em>, if you like. I'm a theme based on Automattic's underscores and I'm meant for hacking so don't use me as a <em>Parent Theme</em> as-is. Instead try turning me into the next, most awesome, WordPress theme out there. That's what I'm here for.
Version: 9.3.5
Version: 9.3.6
------8<----------
Please do this before your actual theme is ready to go live:
Expand All @@ -20,10 +20,10 @@ If you see this, contact the site admin.
/*---------------------------------------------------------------
>>> Air-light theme version information, only for AIR developers
-----------------------------------------------------------------
@version 2023-09-12
@version 2024-01-10
@since 2016-01-28
Tested up to: 6.3.1
Tested up to: 6.4.2
Requires PHP: 7.4
License: MIT License
License URI: LICENSE
Expand Down

0 comments on commit ebb0679

Please sign in to comment.