diff --git a/src/view/segmentation.js b/src/view/segmentation.js index cd601549..12839654 100644 --- a/src/view/segmentation.js +++ b/src/view/segmentation.js @@ -55,6 +55,11 @@ export const handleSegmentation = prompts => { if ( ras ) { handleSeen( prompt, ras ); } + + // Register the overlay in RAS. + if ( isOverlay && ras?.overlays ) { + prompt.overlayId = ras.overlays.add(); + } }; if ( isOverlay ) { const scroll = prompt.getAttribute( 'data-scroll' ); diff --git a/src/view/utils/prompts.js b/src/view/utils/prompts.js index 2fdaee8e..c1a14eca 100644 --- a/src/view/utils/prompts.js +++ b/src/view/utils/prompts.js @@ -33,6 +33,11 @@ export const closeOverlay = event => { parent.style.display = 'none'; } + // Remove the overlay from RAS. + if ( parent.overlayId && window.newspackReaderActivation?.overlays ) { + window.newspackReaderActivation.overlays.remove( parent.overlayId ); + } + event.preventDefault(); };