Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A11y: Wrap ToC Block within nav tag #6084

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4e2f9c1
ToC Links a11y
Tishasoumya-02 Jun 7, 2024
1b67a82
Revert "ToC Links a11y"
Tishasoumya-02 Jun 7, 2024
ce8e8d2
ToC links i18n,a11y
Tishasoumya-02 Jun 7, 2024
5ae5138
test update
Tishasoumya-02 Jun 7, 2024
1bf3cf4
/news
Tishasoumya-02 Jun 7, 2024
2f886ee
Merge branch 'main' into ToC-a11y
Tishasoumya-02 Jun 17, 2024
74ab507
Adjustments for multiple ToC
Tishasoumya-02 Jun 24, 2024
fb6ba78
snapshots update
Tishasoumya-02 Jun 24, 2024
49b5dad
Merge branch 'main' into ToC-a11y
Tishasoumya-02 Jul 19, 2024
e78b371
fix aria-label
Tishasoumya-02 Aug 2, 2024
f0313c0
translations
Tishasoumya-02 Aug 2, 2024
c139b1f
Merge branch 'main' into ToC-a11y
Tishasoumya-02 Aug 2, 2024
13b253c
Merge branch 'main' into ToC-a11y
ichim-david Sep 24, 2024
b5af56e
Merge branch 'main' into ToC-a11y
ichim-david Sep 25, 2024
a4a46b7
Removed title FormattedMessage fallback that would never be shown:
ichim-david Sep 26, 2024
4276b93
updated locales to remove Table of Contents from HorizontalMenu and D…
ichim-david Sep 26, 2024
07bf27e
Use FormattedMessage and undid export messages since we use these mes…
ichim-david Sep 26, 2024
5c7316c
Merge branch 'main' into ToC-a11y
ichim-david Sep 26, 2024
d320207
restore table of contents translation for spanish language
ichim-david Sep 26, 2024
018a216
Merge branch 'main' into ToC-a11y
davisagli Oct 3, 2024
8dca3ca
upgrade guide
davisagli Oct 3, 2024
9eec2cd
Update packages/volto/news/6082.breaking
stevepiercy Oct 4, 2024
ed61fd1
Merge branch 'main' into ToC-a11y
sneridagh Oct 4, 2024
072d101
Merge branch 'main' into ToC-a11y
ichim-david Oct 15, 2024
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
10 changes: 10 additions & 0 deletions packages/volto/locales/ca/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3508,6 +3508,16 @@ msgstr "Taula"
msgid "Table of Contents"
msgstr "Taula de continguts"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3507,6 +3507,16 @@ msgstr "Tabelle"
msgid "Table of Contents"
msgstr "Inhaltsverzeichnis"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3502,6 +3502,16 @@ msgstr ""
msgid "Table of Contents"
msgstr ""

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3509,6 +3509,16 @@ msgstr "Tabla"
msgid "Table of Contents"
msgstr "Tabla de contenidos"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/eu/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3509,6 +3509,16 @@ msgstr "Taula"
msgid "Table of Contents"
msgstr "Edukien taula"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/fi/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3507,6 +3507,16 @@ msgstr "Taulukkoa"
msgid "Table of Contents"
msgstr "Sisällys"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/fr/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3509,6 +3509,16 @@ msgstr "Table"
msgid "Table of Contents"
msgstr "Table des matières"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/hi/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3502,6 +3502,16 @@ msgstr "तालिका"
msgid "Table of Contents"
msgstr "सारांश की तालिका"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/it/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3502,6 +3502,16 @@ msgstr "Tabella"
msgid "Table of Contents"
msgstr "Indice dei contenuti"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/ja/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3507,6 +3507,16 @@ msgstr "テーブル"
msgid "Table of Contents"
msgstr "目次"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/nl/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3506,6 +3506,16 @@ msgstr ""
msgid "Table of Contents"
msgstr ""

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/pt/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3507,6 +3507,16 @@ msgstr "Tabela"
msgid "Table of Contents"
msgstr ""

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/pt_BR/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3508,6 +3508,16 @@ msgstr "Tabela"
msgid "Table of Contents"
msgstr "Tabela de conteúdos"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/ro/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3502,6 +3502,16 @@ msgstr "Tabel"
msgid "Table of Contents"
msgstr "Cuprins"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
12 changes: 11 additions & 1 deletion packages/volto/locales/volto.pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Plone\n"
"POT-Creation-Date: 2024-05-29T18:53:42.120Z\n"
"POT-Creation-Date: 2024-06-07T10:48:04.224Z\n"
"Last-Translator: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
"Language-Team: Plone i18n <plone-i18n@lists.sourceforge.net>\n"
"Content-Type: text/plain; charset=utf-8\n"
Expand Down Expand Up @@ -3504,6 +3504,16 @@ msgstr ""
msgid "Table of Contents"
msgstr ""

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
10 changes: 10 additions & 0 deletions packages/volto/locales/zh_CN/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3508,6 +3508,16 @@ msgstr "表格"
msgid "Table of Contents"
msgstr "表格内容"

#. Default: "Table-Of-Content-Link"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
msgid "Table-Of-Content-Link"
msgstr ""

#. Default: "Table-of-Content-Link"
#: components/manage/Blocks/ToC/variations/HorizontalMenu
msgid "Table-of-Content-Link"
msgstr ""

#. Default: "Tabular view"
#: config/Views
msgid "Tabular view"
Expand Down
1 change: 1 addition & 0 deletions packages/volto/news/6082.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a11y ToC links - @Tishasoumya-02
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
* @module components/manage/Blocks/ToC/View
*/

import React from 'react';
import PropTypes from 'prop-types';
import { map } from 'lodash';
import { List } from 'semantic-ui-react';
import { FormattedMessage, injectIntl } from 'react-intl';
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
import Slugger from 'github-slugger';
import { UniversalLink } from '@plone/volto/components';
import { normalizeString } from '@plone/volto/helpers';

const messages = defineMessages({
link: {
id: 'Table-Of-Content-Link',
defaultMessage: 'Table-Of-Content-Link',
},
});
const RenderListItems = ({ items, data }) => {
const intl = useIntl();
return map(items, (item) => {
const { id, level, title, override_toc, plaintext } = item;
const slug = override_toc
Expand All @@ -21,7 +26,12 @@ const RenderListItems = ({ items, data }) => {
return (
item && (
<List.Item key={id} className={`item headline-${level}`} as="li">
<UniversalLink href={`#${slug}`}>{title}</UniversalLink>
<UniversalLink
href={`#${slug}`}
aria-label={intl.formatMessage(messages.link)}
>
{title}
</UniversalLink>
{item.items?.length > 0 && (
<List
ordered={data.ordered}
Expand Down Expand Up @@ -77,4 +87,4 @@ View.propTypes = {
properties: PropTypes.objectOf(PropTypes.any).isRequired,
};

export default injectIntl(View);
export default View;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { map } from 'lodash';
import { Menu, Dropdown } from 'semantic-ui-react';
import { FormattedMessage, injectIntl } from 'react-intl';
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
import AnchorLink from 'react-anchor-link-smooth-scroll';
import Slugger from 'github-slugger';
import { normalizeString } from '@plone/volto/helpers';

const messages = defineMessages({
link: {
id: 'Table-of-Content-Link',
defaultMessage: 'Table-of-Content-Link',
},
});
const RenderMenuItems = ({ items }) => {
const intl = useIntl();
return map(items, (item) => {
const { id, level, title, override_toc, plaintext } = item;
const slug = override_toc
Expand All @@ -17,7 +23,12 @@ const RenderMenuItems = ({ items }) => {
item && (
<React.Fragment key={id}>
<Menu.Item className={`headline-${level}`}>
<AnchorLink href={`#${slug}`}>{title}</AnchorLink>
<AnchorLink
href={`#${slug}`}
aria-label={intl.formatMessage(messages.link)}
>
{title}
</AnchorLink>
</Menu.Item>
{item.items?.length > 0 && <RenderMenuItems items={item.items} />}
</React.Fragment>
Expand Down Expand Up @@ -201,4 +212,4 @@ View.propTypes = {
properties: PropTypes.objectOf(PropTypes.any).isRequired,
};

export default injectIntl(View);
export default View;
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ exports[`renders a default toc renderer component 1`] = `
role="listitem"
>
<a
aria-label="Table-Of-Content-Link"
className={null}
href="/#hello-this-is-a-sample-page"
onClick={[Function]}
Expand All @@ -29,6 +30,7 @@ exports[`renders a default toc renderer component 1`] = `
role="listitem"
>
<a
aria-label="Table-Of-Content-Link"
className={null}
href="/#test-level-3"
onClick={[Function]}
Expand Down
Loading