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 all 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
5 changes: 5 additions & 0 deletions docs/source/upgrade-guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ The recommended way of generating a project boilerplate is [Cookieplone](https:/
Please update your code to use the `pnpm` based setup.
```

### Table of Contents block markup change

The `View` component for the Table of Contents block was updated to use a `nav` element instead of a `div`.
If you've applied custom styles or shadowed this component, you might need to make adjustments.

### Update needed to project boilerplate generated with `@plone/generator-volto`

```{versionadded} Volto 18.0.0-alpha.42
Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/ca/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3563,8 +3563,7 @@ msgid "Table"
msgstr "Taula"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Taula de continguts"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3562,8 +3562,7 @@ msgid "Table"
msgstr "Tabelle"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Inhaltsverzeichnis"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3557,8 +3557,7 @@ msgid "Table"
msgstr ""

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr ""

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3564,8 +3564,7 @@ msgid "Table"
msgstr "Tabla"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Tabla de contenidos"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/eu/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3564,8 +3564,7 @@ msgid "Table"
msgstr "Taula"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Edukien taula"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/fi/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3562,8 +3562,7 @@ msgid "Table"
msgstr "Taulukkoa"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Sisällys"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/fr/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3564,8 +3564,7 @@ msgid "Table"
msgstr "Table"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Table des matières"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/hi/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3557,8 +3557,7 @@ msgid "Table"
msgstr "तालिका"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "सारांश की तालिका"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/it/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3557,8 +3557,7 @@ msgid "Table"
msgstr "Tabella"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Indice dei contenuti"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/ja/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3562,8 +3562,7 @@ msgid "Table"
msgstr "テーブル"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "目次"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/nl/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3561,8 +3561,7 @@ msgid "Table"
msgstr ""

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr ""

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/pt/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3562,8 +3562,7 @@ msgid "Table"
msgstr "Tabela"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr ""

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/pt_BR/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3563,8 +3563,7 @@ msgid "Table"
msgstr "Tabela"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Tabela de conteúdos"

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/ro/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3557,8 +3557,7 @@ msgid "Table"
msgstr "Tabel"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "Cuprins"

Expand Down
5 changes: 2 additions & 3 deletions 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-09-19T10:10:37.548Z\n"
"POT-Creation-Date: 2024-09-26T14:41:55.000Z\n"
"Last-Translator: Plone i18n <[email protected]>\n"
"Language-Team: Plone i18n <[email protected]>\n"
"Content-Type: text/plain; charset=utf-8\n"
Expand Down Expand Up @@ -3559,8 +3559,7 @@ msgid "Table"
msgstr ""

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr ""

Expand Down
3 changes: 1 addition & 2 deletions packages/volto/locales/zh_CN/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -3563,8 +3563,7 @@ msgid "Table"
msgstr "表格"

#. Default: "Table of Contents"
#: components/manage/Blocks/ToC/variations/DefaultTocRenderer
#: components/manage/Blocks/ToC/variations/HorizontalMenu
#: components/manage/Blocks/ToC/View
msgid "Table of Contents"
msgstr "表格内容"

Expand Down
1 change: 1 addition & 0 deletions packages/volto/news/6082.breaking
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Wrap Table of Contents block in a `nav` tag, instead of a `div` tag, for better representation improving the block accessibility. @Tishasoumya-02 @ichim-david
25 changes: 18 additions & 7 deletions packages/volto/src/components/manage/Blocks/ToC/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
* View toc block.
* @module components/manage/Blocks/ToC/View
*/

import React from 'react';
import PropTypes from 'prop-types';
import { injectIntl } from 'react-intl';
import { FormattedMessage } from 'react-intl';
import cx from 'classnames';
import { Message } from 'semantic-ui-react';
import config from '@plone/volto/registry';
Expand Down Expand Up @@ -86,6 +85,8 @@ export const getBlocksTocEntries = (properties, tocData) => {
*/
const View = (props) => {
const { data } = props;

const title = data.title ? data.title : '';
const { variation } = props;
const metadata = props.metadata || props.properties;
const blocksFieldname = getBlocksFieldname(metadata);
Expand Down Expand Up @@ -165,17 +166,27 @@ const View = (props) => {

const Renderer = variation?.view;
return (
<div className={cx('table-of-contents', variation?.id)}>
{props.mode === 'edit' && !data.title && !tocEntries.length && (
<Message>Table of content</Message>
<nav
aria-label={title && !data.hide_title ? title : ''}
className={cx('table-of-contents', variation?.id)}
>
{props.mode === 'edit' && !title && !tocEntries.length && (
<Message>
{
<FormattedMessage
id="Table of Contents"
defaultMessage="Table of Contents"
/>
}
</Message>
)}

{Renderer ? (
<Renderer {...props} tocEntries={tocEntries} metadata={metadata} />
) : (
<div>View extension not found</div>
)}
</div>
</nav>
);
};

Expand All @@ -188,4 +199,4 @@ View.propTypes = {
properties: PropTypes.objectOf(PropTypes.any).isRequired,
};

export default injectIntl(withBlockExtensions(View));
export default withBlockExtensions(View);
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@
* @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 Slugger from 'github-slugger';
import { UniversalLink } from '@plone/volto/components';
import { normalizeString } from '@plone/volto/helpers';
Expand Down Expand Up @@ -45,18 +43,7 @@ const RenderListItems = ({ items, data }) => {
const View = ({ data, tocEntries }) => {
return (
<>
{data.title && !data.hide_title ? (
<h2>
{data.title || (
<FormattedMessage
id="Table of Contents"
defaultMessage="Table of Contents"
/>
)}
</h2>
) : (
''
)}
{data.title && !data.hide_title ? <h2>{data.title}</h2> : ''}
<List
ordered={data.ordered}
bulleted={!data.ordered}
Expand All @@ -77,4 +64,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,7 +2,6 @@ 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 AnchorLink from 'react-anchor-link-smooth-scroll';
import Slugger from 'github-slugger';
import { normalizeString } from '@plone/volto/helpers';
Expand Down Expand Up @@ -159,18 +158,7 @@ const View = ({ data, tocEntries }) => {

return (
<>
{data.title && !data.hide_title ? (
<h2>
{data.title || (
<FormattedMessage
id="Table of Contents"
defaultMessage="Table of Contents"
/>
)}
</h2>
) : (
''
)}
{data.title && !data.hide_title ? <h2>{data.title}</h2> : ''}
<Menu className="responsive-menu">
<RenderMenuItems items={tocEntries} />
<Dropdown
Expand Down Expand Up @@ -201,4 +189,4 @@ View.propTypes = {
properties: PropTypes.objectOf(PropTypes.any).isRequired,
};

export default injectIntl(View);
export default View;
Loading