Skip to content

Commit eb942a3

Browse files
committed
'Select All' workaround
1 parent b2e6233 commit eb942a3

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

packages/text-annotator/src/SelectionHandler.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,19 @@ export const SelectionHandler = (
271271
// Proper lifecycle management: clear selection first...
272272
selection.clear();
273273

274-
// ...then add annotation to store...
275-
store.addAnnotation({
276-
id: currentTarget.annotation,
277-
bodies: [],
278-
target: currentTarget
279-
});
274+
setTimeout(() => {
275+
// ...then add annotation to store...
276+
store.addAnnotation({
277+
id: currentTarget.annotation,
278+
bodies: [],
279+
target: currentTarget
280+
});
281+
282+
selection.userSelect(currentTarget.annotation, cloneKeyboardEvent(evt));
283+
284+
// Sigh.. not sure there's a reliable timeout. Alternative would be
285+
// to listen to the selectionchange event once?
286+
}, 250);
280287
}
281288

282289
hotkeys(SELECTION_KEYS.join(','), { element: container, keydown: true, keyup: false }, evt => {

0 commit comments

Comments
 (0)