@@ -47,7 +47,9 @@ export class TutorialWizard extends Component<ITutorialWizardProps, ITutorialWiz
4747 }
4848
4949 public override componentDidUpdate ( _prevProps : ITutorialWizardProps , prevState : ITutorialWizardState ) : void {
50- if ( prevState . currentStep !== this . state . currentStep ) {
50+ const { currentStep } = this . state ;
51+
52+ if ( prevState . currentStep !== currentStep ) {
5153 this . syncObserver ( ) ;
5254 }
5355 }
@@ -78,8 +80,10 @@ export class TutorialWizard extends Component<ITutorialWizardProps, ITutorialWiz
7880 }
7981
8082 public open ( ) : void {
83+ const { onStepChange } = this . props ;
84+
8185 this . setState ( { currentStep : 0 } , ( ) => {
82- this . props . onStepChange ?.( 0 ) ;
86+ onStepChange ?.( 0 ) ;
8387 this . portalRef . current ?. open ( {
8488 backgroundOpacity : 0 ,
8589 closeOnEscape : true ,
@@ -94,23 +98,25 @@ export class TutorialWizard extends Component<ITutorialWizardProps, ITutorialWiz
9498 }
9599
96100 private cleanupObserver ( ) : void {
101+ const { targetRect } = this . state ;
102+
97103 this . resizeObserver ?. disconnect ( ) ;
98104 this . resizeObserver = undefined ;
99105 this . observedElement = undefined ;
100- if ( this . state . targetRect ) {
106+ if ( targetRect ) {
101107 this . setState ( { targetRect : undefined } ) ;
102108 }
103109 }
104110
105111 private syncObserver ( ) : void {
106112 const { steps } = this . props ;
107- const { currentStep } = this . state ;
113+ const { currentStep, targetRect } = this . state ;
108114 const step = steps [ currentStep ] ;
109115
110116 if ( ! step . targetSelector ) {
111117 this . resizeObserver ?. disconnect ( ) ;
112118 this . observedElement = undefined ;
113- if ( this . state . targetRect ) {
119+ if ( targetRect ) {
114120 this . setState ( { targetRect : undefined } ) ;
115121 }
116122
0 commit comments