Skip to content

dialogAutoCloser

James Hou edited this page Jan 24, 2021 · 3 revisions

dialogAutoCloser

A simple component that counts down and auto closes a DialogService opened dialog by sending a messageService connected closedialog event.

This is meant to be used with DialogService when launching a Screen Flow as the final step.

However, there are a couple more ways to use it:

  • As a visual countdown progress bar, handling the bubbled closedialog Custom Event by yourself.
  • Refreshing an instance of soqlDatatable by using the uniqueBoundary and isRefreshTable properties.
    • This sends a boundary scoped: refreshsoqldatatable LMS event.

NOTE: It is recommended you provide this component a uniqueBoundary scoped to its caller, otherwise it may close more dialogs than intended if Tab-Focused Dialogs is enabled.

<template>
  <c-message-service></c-message-service>

  <lightning-layout horizontal-align="center" multiple-rows>
    <lightning-layout-item flexibility="shrink">
      {messageTemplate}
    </lightning-layout-item>
    <lightning-layout-item size="12">
      <lightning-progress-bar value={progress}></lightning-progress-bar>
    </lightning-layout-item>
  </lightning-layout>
</template>
@api messageTemplate = 'Auto closing in {timer} seconds';
@api timer = 5;

...

renderedCallback() {
  if (this._isRendered) {
    return;
  }
  this._isRendered = true;
  this._startProgressInterval();
  this._startTimerInterval();
}

...

Specification

Attributes

name type access required default description
messageTemplate String public no Auto closing in {timer} seconds Message to display to user while countdown is running
timer Number public no 5 Seconds until the component launches the closedialog LMS event

Public Methods

None

Clone this wiki locally