Skip to content
Open
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
15 changes: 3 additions & 12 deletions js/TrickleButtonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class TrickleButtonView extends ComponentView {
}

initialize() {
this.openPopupCount = 0;
this.isAwaitingPopupClose = false;
this.wasButtonClicked = false;
this.calculateButtonState();
Expand All @@ -46,7 +45,7 @@ class TrickleButtonView extends ComponentView {
* Taking account of open popups, recalculate the button visible and enabled states
*/
calculateButtonState() {
const isDisabledByPopups = (this.openPopupCount > 0);
const isDisabledByPopups = a11y.isPopupOpen;
this.model.calculateButtonState(isDisabledByPopups, this.wasButtonClicked);
}

Expand Down Expand Up @@ -83,22 +82,14 @@ class TrickleButtonView extends ComponentView {
});
}

/**
* Keep count of the number of open popups
*/
onPopupOpened() {
this.openPopupCount++;
const shouldUserInteractWithButton = (this.model.isStepUnlocked() && !this.model.isFinished());
if (!shouldUserInteractWithButton) return;
this.updateButtonState();
}

/**
* Keep count of the number of open popups
*/
async onPopupClosed() {
this.openPopupCount--;
if (this.openPopupCount) return;
if (a11y.isPopupOpen) return;
if (this.isAwaitingPopupClose) {
// Had completed with an open popup, perform final part of finishing
return this.finish();
Expand Down Expand Up @@ -173,7 +164,7 @@ class TrickleButtonView extends ComponentView {
[`change:${completionAttribute}`]: this.onParentComplete
});
if (controller.isKilled) return;
if (this.openPopupCount > 0) {
if (a11y.isPopupOpen) {
// Has completed with an open popup, defer finish until popup closed
this.isAwaitingPopupClose = true;
return;
Expand Down
Loading