Skip to content

Commit

Permalink
fix(www): reset the contact view if the user navigates back (#1737)
Browse files Browse the repository at this point in the history
* Reset the contact view when a user clicks the "back" button.

* Add a test case.

* Use strict equality.
  • Loading branch information
sbruens authored Oct 4, 2023
1 parent c462098 commit 64cf473
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/www/ui_components/app-root.js
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@ export class AppRoot extends mixinBehaviors([AppLocalizeBehavior], PolymerElemen
}

_goBack() {
if (this.page === 'contact') {
// TODO: Replace with `this.$.contactView` once the element is no longer inside a `dom-if`.
this.shadowRoot.querySelector('#contactView').reset();
}

// If there is a navigation on the webview's history stack, pop it off to go back.
if (history.length > 1) {
history.back();
Expand Down
12 changes: 12 additions & 0 deletions src/www/views/contact_view/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,18 @@ describe('ContactView client variant', () => {
expect(exitCard.textContent).toContain('experiencing high support volume');
});

it('resets the view on `reset()`', async () => {
const radioButton = el.shadowRoot!.querySelectorAll('mwc-formfield mwc-radio')[0] as HTMLElement;
radioButton.click();
await nextFrame();

el.reset();
await nextFrame();

const exitCard = el.shadowRoot!.querySelector('outline-card')!;
expect(exitCard).toBeNull();
});

describe('when the user selects that they have no open tickets', () => {
let issueSelector: Select;

Expand Down
2 changes: 1 addition & 1 deletion src/www/views/contact_view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class ContactView extends LitElement {
this.step = Step.FORM;
}

private reset() {
reset() {
this.isFormSubmitting = false;
this.showIssueSelector = false;
this.step = Step.ISSUE_WIZARD;
Expand Down

0 comments on commit 64cf473

Please sign in to comment.