Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix turning off modal overlay in successive tour starts #277

Merged
merged 2 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions addon/services/tour.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export default Service.extend(Evented, {
* @public
*/
cancel() {
this._showOrHideModal('hide');
get(this, 'tourObject').cancel();
},

Expand All @@ -64,6 +65,7 @@ export default Service.extend(Evented, {
* @public
*/
complete() {
this._showOrHideModal('hide');
get(this, 'tourObject').complete();
},

Expand All @@ -72,6 +74,7 @@ export default Service.extend(Evented, {
* @public
*/
hide() {
this._showOrHideModal('hide');
get(this, 'tourObject').hide();
},

Expand Down Expand Up @@ -162,7 +165,6 @@ export default Service.extend(Evented, {
tourObject.on('cancel', bind(this, 'onTourFinish', 'cancel'));

set(this, 'tourObject', tourObject);
this._initModalOverlay();
},

/**
Expand Down Expand Up @@ -278,7 +280,6 @@ export default Service.extend(Evented, {
['hide', 'destroy'].forEach(event => {
currentStep.on(event, () => {
unhighlightStepTarget(currentStep);
this._showOrHideModal('hide');
});
});

Expand Down Expand Up @@ -320,6 +321,7 @@ export default Service.extend(Evented, {
this._modalOverlayElem = createModalOverlay();
this._modalOverlayOpening = getModalMaskOpening(this._modalOverlayElem);

// don't show yet -- each step will control that
this._showOrHideModal('hide');

document.body.appendChild(this._modalOverlayElem);
Expand Down
15 changes: 6 additions & 9 deletions tests/acceptance/ember-shepherd-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,12 @@ module('Acceptance | Tour functionality tests', function(hooks) {
test('Displaying the modal during tours when modal mode is enabled', async function(assert) {
await visit('/');

const modalOverlay = document.querySelector(`#${modalElementIds.modalOverlay}`);

assert.ok(modalOverlay, 'modal overlay is present in the DOM');
assert.equal(getComputedStyle(modalOverlay).display, 'none', 'modal overlay is present but not displayed before the tour starts');
assert.notOk(document.body.classList.contains(modalClassNames.isVisible), `Body has no class of "${modalClassNames.isVisible}" when shepherd is not active`);
assert.equal(document.querySelector(`#${modalElementIds.modalOverlay}`), null, 'modal overlay is not present in the DOM before any tour is started');

await click('.toggleHelpModal');

const modalOverlay = document.querySelector(`#${modalElementIds.modalOverlay}`);

assert.equal(getComputedStyle(modalOverlay).display, 'block', 'modal overlay is present and displayed after the tour starts');

assert.ok(document.body.classList.contains('shepherd-active'), 'Body gets class of shepherd-active, when shepherd becomes active');
Expand All @@ -149,13 +147,12 @@ module('Acceptance | Tour functionality tests', function(hooks) {
test('Hiding the modal during tours when modal mode is not enabled', async function(assert) {
await visit('/');

const modalOverlay = document.querySelector(`#${modalElementIds.modalOverlay}`);

assert.ok(modalOverlay, 'modal overlay is present in the DOM');
assert.equal(getComputedStyle(modalOverlay).display, 'none', 'modal overlay is present but not displayed before the tour starts');
assert.equal(document.querySelector(`#${modalElementIds.modalOverlay}`), null, 'modal overlay is not present in the DOM before any tour is started');

await click('.toggleHelpNonmodal');

const modalOverlay = document.querySelector(`#${modalElementIds.modalOverlay}`);

assert.equal(getComputedStyle(modalOverlay).display, 'none', 'modal overlay is present but not displayed after the tour starts');

assert.ok(document.body.classList.contains('shepherd-active'), 'Body gets class of shepherd-active, when shepherd becomes active');
Expand Down