Skip to content

Commit 8f8a294

Browse files
authoredOct 31, 2024··
Improve info panel focusability (fixes #1069) (#1171)
* Adds a tabindex to the right info panel's main element so it can be focused regardless of whether it has focus-able content * check for scrolling before setting/unsetting tabindex and aria label. make elements articles so they'll be readable by screenreaders.
1 parent c394516 commit 8f8a294

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed
 

‎src/content-handlers/iiif/modules/uv-dialogues-module/MoreInfoDialogue.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class MoreInfoDialogue extends Dialogue<
4949
);
5050
this.$content.append(this.$title);
5151

52-
this.$metadata = $('<div class="iiif-metadata-component"></div>');
52+
this.$metadata = $('<article class="iiif-metadata-component"></article>');
5353
this.$content.append(this.$metadata);
5454

5555
this.metadataComponent = new MetadataComponent({
@@ -98,5 +98,18 @@ export class MoreInfoDialogue extends Dialogue<
9898

9999
resize(): void {
100100
this.setDockedPosition();
101+
102+
// always put tabindex on, so the metadata is focusable,
103+
// just in case there's something wrong with the height
104+
// comparison below
105+
this.$metadata.attr('tabindex', 0);
106+
this.$metadata.attr('aria-label', this.config.content.title);
107+
108+
// if metadata's first group's height is lte than metadata (200px fixed I think),
109+
// there's no scroll happening, so no focus needed, and no aria label either
110+
if(this.$metadata.find('.groups').first().height() <= this.$metadata.height()) {
111+
this.$metadata.removeAttr('tabindex');
112+
this.$metadata.removeAttr('aria-label');
113+
}
101114
}
102115
}

‎src/content-handlers/iiif/modules/uv-moreinforightpanel-module/MoreInfoRightPanel.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class MoreInfoRightPanel extends RightPanel<MoreInfoRightPanelConfig> {
3333

3434
this.setTitle(this.config.content.title);
3535

36-
this.$metadata = $('<div class="iiif-metadata-component"></div>');
36+
this.$metadata = $('<article class="iiif-metadata-component"></article>');
3737
this.$main.append(this.$metadata);
3838

3939
this.metadataComponent = new MetadataComponent({
@@ -141,5 +141,18 @@ export class MoreInfoRightPanel extends RightPanel<MoreInfoRightPanelConfig> {
141141
this.$main.height(
142142
this.$element.height() - this.$top.height() - this.$main.verticalMargins()
143143
);
144+
145+
// always put tabindex on, so the main is focusable,
146+
// just in case there's something wrong with the height
147+
// comparison below
148+
this.$main.attr('tabindex', 0);
149+
this.$main.attr('aria-label', this.config.content.title);
150+
151+
// if metadata's height lte main's, no scroll, so no focus needed
152+
// and no aria label either
153+
if(this.$metadata.height() <= this.$main.height()) {
154+
this.$main.removeAttr('tabindex');
155+
this.$main.removeAttr('aria-label');
156+
}
144157
}
145158
}

0 commit comments

Comments
 (0)
Please sign in to comment.