Skip to content

Commit

Permalink
Fix settings heading hierarchy: do not use h3 for description
Browse files Browse the repository at this point in the history
as it distorts the outline which is detrimental to accessibility;
instead use the `<header>` pattern as recommended by W3C in:
https://www.w3.org/TR/2017/WD-html52-20170228/common-idioms-without-dedicated-elements.html

Also, do not rely on style the caret icon by element but by class name
(using this pattern reduces cognitive burden and improves performance).
  • Loading branch information
krassowski committed Feb 13, 2022
1 parent c5df985 commit a6761d7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 11 additions & 5 deletions packages/settingeditor/src/SettingsFormEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,17 @@ export class SettingsFormEditor extends React.Component<
this.props.onSelect(this.props.settings.id);
}}
>
<div className="jp-SettingsTitle">
<icon.react tag="span" elementPosition="center" />
<h2> {this.props.settings.schema.title} </h2>
<h3> {this.props.settings.schema.description} </h3>
</div>
<header className="jp-SettingsTitle">
<icon.react
tag="span"
elementPosition="center"
className="jp-SettingsTitle-caret"
/>
<h2>{this.props.settings.schema.title}</h2>
<div className="jp-SettingsHeader-description">
{this.props.settings.schema.description}
</div>
</header>
{this.state.isModified && (
<button className="jp-RestoreButton" onClick={this.reset}>
{trans.__('Restore to Defaults')}
Expand Down
4 changes: 2 additions & 2 deletions packages/settingeditor/style/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ ul.jp-PluginList li.jp-mod-selected span.jp-PluginList-icon.jp-FileIcon {
margin: 1em;
}

.jp-SettingsPanel .jp-SettingsHeader h3 {
.jp-SettingsPanel .jp-SettingsHeader-description {
font-size: var(--jp-content-font-size2);
color: var(--jp-ui-font-color1);
font-weight: 200;
Expand Down Expand Up @@ -381,7 +381,7 @@ ul.jp-PluginList li.jp-mod-selected span.jp-PluginList-icon.jp-FileIcon {
padding-left: 1em;
}

.jp-SettingsPanel .jp-SettingsTitle span {
.jp-SettingsPanel .jp-SettingsTitle-caret {
width: 2em;
}

Expand Down

0 comments on commit a6761d7

Please sign in to comment.