Skip to content

Commit

Permalink
check for scrolling before setting/unsetting tabindex and aria label.…
Browse files Browse the repository at this point in the history
… make elements articles so they'll be readable by screenreaders.
  • Loading branch information
LlGC-jop committed Oct 24, 2024
1 parent 6cfdb09 commit d7622fe
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class MoreInfoDialogue extends Dialogue<
);
this.$content.append(this.$title);

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

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

resize(): void {
this.setDockedPosition();

// always put tabindex on, so the metadata is focusable,
// just in case there's something wrong with the height
// comparison below
this.$metadata.attr('tabindex', 0);
this.$metadata.attr('aria-label', this.config.content.title);

// if metadata's first group's height is lte than metadata (200px fixed I think),
// there's no scroll happening, so no focus needed, and no aria label either
if(this.$metadata.find('.groups').first().height() <= this.$metadata.height()) {
this.$metadata.removeAttr('tabindex');
this.$metadata.removeAttr('aria-label');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ export class MoreInfoRightPanel extends RightPanel<MoreInfoRightPanelConfig> {

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

this.$metadata = $('<div class="iiif-metadata-component"></div>');
this.$metadata = $('<article class="iiif-metadata-component"></article>');
this.$main.append(this.$metadata);
this.$main.attr('tabindex', 0);

this.metadataComponent = new MetadataComponent({
target: <HTMLElement>this.$metadata[0],
Expand Down Expand Up @@ -142,5 +141,18 @@ export class MoreInfoRightPanel extends RightPanel<MoreInfoRightPanelConfig> {
this.$main.height(
this.$element.height() - this.$top.height() - this.$main.verticalMargins()
);

// always put tabindex on, so the main is focusable,
// just in case there's something wrong with the height
// comparison below
this.$main.attr('tabindex', 0);
this.$main.attr('aria-label', this.config.content.title);

// if metadata's height lte main's, no scroll, so no focus needed
// and no aria label either
if(this.$metadata.height() <= this.$main.height()) {
this.$main.removeAttr('tabindex');
this.$main.removeAttr('aria-label');
}
}
}

0 comments on commit d7622fe

Please sign in to comment.