Skip to content

Commit

Permalink
Ref #265448 Fix error where selector in URL is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
tedw87 committed Mar 22, 2024
1 parent 15d3ddb commit e61425a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { serializeNodes } from '@plone/volto-slate/editor/render';
import { Link } from 'react-router-dom';
import { getBlocks } from '@plone/volto/helpers/Blocks/Blocks';
import linkSVG from '@plone/volto/icons/link.svg';

import './less/slate-anchors.less';

export const createSlateParagraph = (text) => {
Expand All @@ -16,6 +15,10 @@ export const serializeText = (text) => {
return isArray(text) ? serializeNodes(text) : text;
};

function removeSpecialCharacters(str) {
return str.replace(/[^a-zA-Z0-9]/g, '');
}

export const toSlug = (url) => Slugger.slug(url);

export const waitForElm = (selector) => {
Expand Down Expand Up @@ -52,7 +55,7 @@ export const scrollToTarget = (target, offsetHeight = 0) => {
};

export const openAccordionIfContainsAnchors = (anchor) => {
waitForElm(anchor).then((elm) => {
waitForElm(removeSpecialCharacters(anchor)).then((elm) => {
if (elm.closest('.accordion')) {
const comp = elm.closest('.accordion')?.querySelector('.title');
if (!comp?.className?.includes('active')) {
Expand Down

0 comments on commit e61425a

Please sign in to comment.