@@ -7,10 +7,6 @@ import { Card, CardActions, CardContent, CardHeader, CardTitle } from "../Card";
77import { SimpleDialog } from "../Dialog" ;
88
99export interface VisualTourProps {
10- /** The CSS query of the container element that contains the feature that will be given a tour of.
11- * If element highlighting is enabled, this will grey out every other element in the container element.
12- * Default: body*/
13- containerElementQuery ?: string ;
1410 /** The steps of the tour. */
1511 steps : VisualTourStep [ ] ;
1612 /** Called when the tour is cancelled or closed at then end. This should usually remove the component from the outside. */
@@ -36,12 +32,10 @@ export interface VisualTourStep {
3632/** This should be used for defining steps in a separate object/file. Use with 'satisfies' after the object definition. */
3733export type VisualTourStepDefinitions = Record < string , Partial < VisualTourStep > > ;
3834
39- const containerHighlightClass = `${ eccgui } -visual-tour__container` ;
4035const highlightElementClass = `${ eccgui } -visual-tour__highlighted-element` ;
4136
4237/** A visual tour multi-step tour of the current view. */
4338export const VisualTour = ( {
44- containerElementQuery = "body" ,
4539 steps,
4640 onClose,
4741 closeLabel = "Close" ,
@@ -62,16 +56,9 @@ export const VisualTour = ({
6256 const hasNextStep = currentStepIndex + 1 < steps . length ;
6357 const hasPreviousStep = currentStepIndex > 0 ;
6458 // Configure optional highlighting
65- const element = document . querySelector ( containerElementQuery ) ;
66- let elementToHighlight : Element | null = null ;
67- if ( element ) {
68- if ( step . highlightElementQuery ) {
69- elementToHighlight = document . querySelector ( step . highlightElementQuery ) ;
70- if ( elementToHighlight ) {
71- element . classList . add ( containerHighlightClass ) ;
72- elementToHighlight . classList . add ( highlightElementClass ) ;
73- }
74- }
59+ const elementToHighlight = ! ! step . highlightElementQuery && document . querySelector ( step . highlightElementQuery ) ;
60+ if ( elementToHighlight ) {
61+ elementToHighlight . classList . add ( highlightElementClass ) ;
7562 }
7663 const titleSuffix = ` ${ currentStepIndex + 1 } / ${ steps . length } ` ;
7764 const actionButtons = [
@@ -112,7 +99,6 @@ export const VisualTour = ({
11299 }
113100 return ( ) => {
114101 // Remove previous element highlight
115- document . querySelector ( containerElementQuery ) ?. classList . remove ( containerHighlightClass ) ;
116102 document . querySelector ( `.${ highlightElementClass } ` ) ?. classList . remove ( highlightElementClass ) ;
117103 } ;
118104 } , [ currentStepIndex ] ) ;
0 commit comments