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

Constrain input for Step.options.buttons to an array of buttons. #271

Merged
merged 3 commits into from
Oct 12, 2018

Conversation

BrianSipple
Copy link
Contributor

@BrianSipple BrianSipple commented Oct 12, 2018

Closes #243

@rwwagner90 This should also fix our flaky buttons test that was occasionally failing on Travis.

index.md Outdated
@@ -173,21 +173,21 @@ the step will execute. For example:
},
```
- `classes`: Extra classes to add to the step. `shepherd-theme-arrows` will give you our theme.
- `buttons`: An array of buttons to add to the step. By default we add a Next button which triggers `next()`, set this to false
- `buttons`: An array of buttons to add to the step. These will be rendered in a footer below the main body text.
to disable. Each button in the array is an object of the format:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text is messed up. Got some random sentence fragments. The bullet points below also should not have been moved, as they are now in line with buttons, rather than nested under it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eww... should be fixed now

src/js/step.js Show resolved Hide resolved
test/cypress/integration/test.acceptance.js Outdated Show resolved Hide resolved
@@ -140,11 +141,6 @@ describe('Shepherd Acceptance Tests', () => {
.contains('Shepherd is a JavaScript library')
.should('exist')
.and('be.visible');

// Step twp text should be hidden
cy.contains('Including Shepherd is easy!')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this? We should keep the test functionality in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was wrong when I added it in the first place.

The hidden steps souldn't exist in the DOM at all. And also, Cy works in a way that it will try to wait until it finds something -- which causes it to hang here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless we changed something, hidden steps definitely should exist in the DOM. Once a step is created and inserted into the DOM, it remains there, but is just set to hidden=true. In this case, it may not have been inserted into the DOM yet, but if that is the case, we should do a couple next/back clicks to make sure it is inserted into the DOM, and hidden when on another step. Not sure if we already have tests covering that or not.

Copy link
Contributor Author

@BrianSipple BrianSipple Oct 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set this.el to hidden, but then we also call hide on the tippy instance.

  hide() {
    this.trigger('before-hide');

    if (this.el) {
      this.el.hidden = true;
      // We need to manually set styles for < IE11 support
      this.el.style.display = 'none';
    }

    document.body.('data-shepherd-step');

    if (this.target) {
      this.target.classList.remove('shepherd-enabled', 'shepherd-target');
    }

    if (this.tooltip) {
      this.tooltip.hide();
    }

    this.trigger('hide');
  }

Since the former is contained in the later, it gets removed from the DOM

test/unit/test.step.js Show resolved Hide resolved
src/js/step.js Show resolved Hide resolved
@RobbieTheWagner RobbieTheWagner merged commit aa1a8bc into master Oct 12, 2018
@RobbieTheWagner RobbieTheWagner deleted the clean-buttons-logic branch October 12, 2018 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hide buttons if none are passed to Step.options.buttons
2 participants