Skip to content
Draft
Changes from all commits
Commits
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
49 changes: 48 additions & 1 deletion src/customizations/volto/components/theme/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @module components/theme/Header/Header
*/

import React /*, { useEffect, useState } */ from 'react';
import React, { useEffect } from 'react';

import PropTypes from 'prop-types';

Expand All @@ -21,7 +21,54 @@ import {
} from 'design-comuni-plone-theme/components/ItaliaTheme';
import { Headers } from 'design-react-kit';

const useDisableHeaderInteractions = () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ci può stare ma non lo metterei dentro al componente dell'header, farei un file js separato che butti in pagina con appExtrast dal config

useEffect(() => {
const body = document.body;

const disableHeader = () => {
if (
body.classList.contains('cms-ui') &&
body.classList.contains('section-edit')
) {
const header = document.querySelector('header');
if (!header) return;

const focusables = header.querySelectorAll(
'a, button, input, select, textarea, [tabindex], .it-socials a',
);

[...focusables].forEach((item) => {
item.setAttribute('tabIndex', '-1');
item.setAttribute('aria-hidden', 'true');
// item.style.pointerEvents = 'none'; - disabilitare il mouse click?
});
}
};

disableHeader();

const bodyObserver = new MutationObserver(disableHeader);
bodyObserver.observe(body, {
attributes: true,
attributeFilter: ['class'],
});

const header = document.querySelector('header');
let headerObserver;
if (header) {
headerObserver = new MutationObserver(disableHeader);
headerObserver.observe(header, { childList: true, subtree: true });
}

return () => {
bodyObserver.disconnect();
headerObserver?.disconnect();
};
}, []);
};

const Header = ({ pathname }) => {
useDisableHeaderInteractions();
// const [mini, setMini] = useState(false);

// const handleScroll = () => {
Expand Down