Skip to content

Commit 4a13636

Browse files
committed
Add tabbable option to Highlight object
1 parent 66828d2 commit 4a13636

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/Highlight.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface IHighlightData {
1414
export interface IOptions {
1515
skipIDsBy?: RegExp;
1616
formatMessage: (descriptor: { id: string }, values: { style: IHighlightData['style'] }) => string;
17+
tabbable?: boolean;
1718
}
1819

1920
export default class Highlight {

src/Highlighter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ interface IOptions {
2121
onSelect?: (highlights: Highlight[], newHighlight?: Highlight) => void;
2222
onFocusIn?: (highlight: Highlight) => void;
2323
onFocusOut?: (highlight: Highlight) => void;
24+
tabbable?: boolean;
2425
}
2526

2627
export default class Highlighter {
@@ -42,6 +43,7 @@ export default class Highlighter {
4243
onFocusOut: () => {
4344
this.clearFocusedStyles();
4445
},
46+
tabbable: true,
4547
...options,
4648
};
4749
this.debouncedSnapSelection = debounce(this.snapSelection, ON_SELECT_DELAY);

src/injectHighlightWrappers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ function createAndInsertNodeForScreenReaders(highlight: Highlight, element: HTML
7676
node.setAttribute('aria-label', ariaLabel);
7777

7878
if (position === 'start') {
79-
node.setAttribute('tabindex', '0');
79+
if (highlight.options.tabbable) {
80+
node.setAttribute('tabindex', '0');
81+
}
8082
element.prepend(node);
8183
} else {
8284
element.append(node);

0 commit comments

Comments
 (0)