Skip to content

Commit

Permalink
[E] Restore focus to previous after deleting a highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
1aurend committed May 20, 2024
1 parent 131b8e0 commit 485fd75
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,16 @@ class TextNode extends Component {
}
: {};

const previousTabIndex = previous ? { tabIndex: -1 } : {};

const props = {
key: index,
className: classes,
"data-removable-highlight-id": removableHighlightId,
"data-text-annotation-ids": textAnnotationIds,
"data-annotation-ids": map[index].map(a => a.id),
...interactiveAttributes
...interactiveAttributes,
...previousTabIndex
};

const Tag = interactiveAttributes.href ? "a" : "span";
Expand Down
2 changes: 1 addition & 1 deletion client/src/reader/containers/annotation/Annotatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export class Annotatable extends Component {
);
this.appendLastSelectionAnnotation(selectionAnnotation);
this.resetState({
restoreFocusTo: this.selectableRef,
restoreFocusTo: this.pendingAnnotationNode,
restoreSelectionTo: this.pendingAnnotationNode
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,10 @@ export default `
}
}
}
.previous {
&:focus-visible {
outline: 2px solid var(--focus-color);
}
}
`;

0 comments on commit 485fd75

Please sign in to comment.