Skip to content
Snippets Groups Projects
Unverified Commit 5082060f authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3244621 by mherchel, rikki_iki, catch, cathwaldron, rachel_norfolk,...

Issue #3244621 by mherchel, rikki_iki, catch, cathwaldron, rachel_norfolk, alexpott, Gábor Hojtsy: Olivero: JS error when secondary tabs are present

(cherry picked from commit f8a197f5)
parent bd80b71a
No related branches found
No related tags found
24 merge requests!2496Issue #3222757 by lauriii, Wim Leers, nod_, rachel_norfolk, itmaybejj,...,!2366Issue #3285105 by Daniel Arend,!2304Issue #3258987: Class "Drupal\Core\Utility\Error" not found in _drupal_error_handler_real() due to bug in PHP 8.1.0-8.1.5,!2148Issue #3270899: Remove Color module from core,!2136Issue #3227824: Move the linkset functionality from the decoupled menus contributed module to core's system module,!2071Issue #927570: Setting 403 or 404 handler to a page that redirects leads to endless loop,!1975Issue #3269749: losing query params from user to user/login redirect,!1959Issue #3236497: Allow other modules to opt out of security release message from update_page_top,!1481Issue #3252562: Allow functions that accept no arguments to be used as callable,!1443Issue #3075230: Provide menu link with disable option [Node Add Form],!1387Draft: Resolve #2511878 "Support enclosure field",!1377Issue #3204015: Replace Toolbar BackboneJS usage with VanillaJS equivalent,!1356Issue #3076171: Provide a new library to replace jQuery UI autocomplete,!1321Issue #3239123: Refactor (if feasible) uses of the jQuery text function to use vanillaJS,!1294Issue #3204011: Replace Tour BackboneJS usage with VanillaJS equivalent (10.0.x),!1282Issue #3227824: Add the decoupled menus module to core,!1269Issue #3239134: Refactor (if feasible) uses of the jQuery val function to use VanillaJS,!1262Issue #3239500: Add Array.includes polyfill to support IE11 and Opera Mini,!1229Issue #3225621: Use media query event listener instead of a listener on the resize event,!1159Convert dblog entries into entities,!799Issue #3214332: Preview content is broken in Claro.,!776Resolve #85494 "Use email verification 9.3.x",!558Resolve #3020422 "Toolbar style update",!231Issue #2671162: summary text wysiwyg patch working fine on 9.2.0-dev
const primaryTabsWrapper = '[data-drupal-nav-primary-tabs]';
const activeTab = '.tabs__tab.is-active';
const inactiveTab = '.tabs__tab:not(.is-active)';
const mobileToggle = `${activeTab} .tabs__trigger`;
module.exports = {
'@tags': ['core', 'olivero'],
before(browser) {
browser
.drupalInstall({
setupFile:
'core/tests/Drupal/TestSite/TestSiteOliveroInstallTestScript.php',
installProfile: 'minimal',
})
.drupalCreateUser({
name: 'user',
password: '123',
permissions: ['administer nodes'],
})
.drupalLogin({ name: 'user', password: '123' });
browser.resizeWindow(1600, 800);
},
after(browser) {
browser.drupalUninstall();
},
'Verify desktop primary tab display': (browser) => {
browser
.drupalRelativeURL('/node/1')
.waitForElementVisible(primaryTabsWrapper)
.assert.visible(activeTab)
.assert.visible(inactiveTab)
.assert.not.visible(mobileToggle);
},
'Verify mobile tab display and click functionality': (browser) => {
browser
.resizeWindow(699, 800)
.drupalRelativeURL('/node/1')
.waitForElementVisible(primaryTabsWrapper)
.assert.visible(activeTab)
.assert.not.visible(inactiveTab)
.assert.visible(mobileToggle)
.assert.attributeEquals(mobileToggle, 'aria-expanded', 'false')
.click(mobileToggle)
.waitForElementVisible(inactiveTab)
.assert.attributeEquals(mobileToggle, 'aria-expanded', 'true')
.click(mobileToggle)
.waitForElementNotVisible(inactiveTab)
.assert.attributeEquals(mobileToggle, 'aria-expanded', 'false');
},
};
/**
* @file
* Provides interactivity for showing and hiding the tabs at mobile widths.
* Provides interactivity for showing and hiding the primary tabs at mobile widths.
*/
((Drupal, once) => {
/**
* Initialize the tabs.
* Initialize the primary tabs.
*
* @param {HTMLElement} el
* The DOM element containing the tabs.
* The DOM element containing the primary tabs.
*/
function init(el) {
const tabs = el.querySelector('.tabs');
......@@ -16,7 +16,7 @@
const activeTab = tabs.querySelector('.is-active');
/**
* Determines if tabs are expanded for mobile layouts.
* Determines if primary tabs are expanded for mobile layouts.
*
* @return {boolean}
* Whether the tabs trigger element is expanded.
......@@ -26,7 +26,7 @@
}
/**
* Controls tab visibility on click events.
* Controls primary tab visibility on click events.
*
* @param {Event} e
* The event object.
......@@ -54,16 +54,18 @@
}
/**
* Initialize the tabs.
* Initialize the primary tabs.
*
* @type {Drupal~behavior}
*
* @prop {Drupal~behaviorAttach} attach
* Display tabs according to the screen width.
* Display primary tabs according to the screen width.
*/
Drupal.behaviors.tabs = {
Drupal.behaviors.primaryTabs = {
attach(context) {
once('olivero-tabs', '[data-drupal-nav-tabs]', context).forEach(init);
once('olivero-tabs', '[data-drupal-nav-primary-tabs]', context).forEach(
init,
);
},
};
})(Drupal, once);
......@@ -35,9 +35,9 @@
tabs.querySelector('.tabs__trigger').addEventListener('click', handleTriggerClick);
}
Drupal.behaviors.tabs = {
Drupal.behaviors.primaryTabs = {
attach: function attach(context) {
once('olivero-tabs', '[data-drupal-nav-tabs]', context).forEach(init);
once('olivero-tabs', '[data-drupal-nav-primary-tabs]', context).forEach(init);
}
};
})(Drupal, once);
\ No newline at end of file
......@@ -18,13 +18,13 @@
{% if primary %}
<h2 id="primary-tabs-title" class="visually-hidden">{{ 'Primary tabs'|t }}</h2>
<nav role="navigation" class="tabs-wrapper" aria-labelledby="primary-tabs-title" data-drupal-nav-tabs>
<nav role="navigation" class="tabs-wrapper" aria-labelledby="primary-tabs-title" data-drupal-nav-primary-tabs>
<ul class="tabs tabs--primary">{{ primary }}</ul>
</nav>
{% endif %}
{% if secondary %}
<h2 id="secondary-tabs-title" class="visually-hidden">{{ 'Secondary tabs'|t }}</h2>
<nav role="navigation" class="tabs-wrapper" aria-labelledby="secondary-tabs-title" data-drupal-nav-tabs>
<nav role="navigation" class="tabs-wrapper" aria-labelledby="secondary-tabs-title">
<ul class="tabs tabs--secondary">{{ secondary }}</ul>
</nav>
{% endif %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment