Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions frontend/src/components/participant_view/participant_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import './participant_help_panel';
import './participant_nav';

import {MobxLitElement} from '@adobe/lit-mobx';
import {reaction} from 'mobx';
import {CSSResultGroup, html, nothing} from 'lit';
import {customElement, property, state} from 'lit/decorators.js';

Expand Down Expand Up @@ -64,6 +65,35 @@ export class ParticipantView extends MobxLitElement {

@state() isStartExperimentLoading = false;

private stageReactionDisposer?: () => void;

override connectedCallback() {
super.connectedCallback();
this.stageReactionDisposer = reaction(
() => this.participantService.currentStageViewId,
async () => {
// Wait for Lit to re-render with the new stage component
await this.updateComplete;
const previewer = this.shadowRoot?.querySelector(
'.participant-previewer',
);
previewer?.scrollTo(0, 0);
// Stage components have their own overflow:auto on :host,
// so scroll the stage element too.
previewer
?.querySelector(
':scope > :not(participant-header):not(participant-nav)',
)
?.scrollTo(0, 0);
},
);
}

override disconnectedCallback() {
super.disconnectedCallback();
this.stageReactionDisposer?.();
}

override render() {
const stageId = this.participantService.currentStageViewId;
const stage = this.experimentService.getStage(stageId ?? '');
Expand Down