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: consistent event name triggering in components #10949

Merged
merged 11 commits into from Oct 25, 2018
Merged

fix: consistent event name triggering in components #10949

merged 11 commits into from Oct 25, 2018

Conversation

DanielRuf
Copy link
Contributor

@DanielRuf DanielRuf commented Feb 17, 2018

offcanvas

  • rename closed.zf.offcanvas to close.zf.offcanvas
  • trigger closed.zf.offcanvas when the transition has ended
  • tests: change test for close.zf.offcanvas, add test for closed.zf.off

See #8727

  • update / add unit test
  • update docs

@DanielRuf DanielRuf changed the title rename closed.zf.offcanvas to close.zf.offcanvas fix: rename closed.zf.offcanvas to close.zf.offcanvas Feb 17, 2018
Copy link
Contributor

@ncoden ncoden left a comment

Choose a reason for hiding this comment

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

Not only a fix as it introduce a new event and sinifically change when closed is triggered.

So LGTM for v6.5 but I would like to make this behavior consistent across all components. So i'm not merging it right now.

@DanielRuf
Copy link
Contributor Author

Not only a fix as it introduce a new event and sinifically change when closed is triggered.

So LGTM for v6.5 but I would like to make this behavior consistent across all components. So i'm not merging it right now.

Definitely, should I also create an issue and link the changes/PRs for the other components there then?

I remember seeing some issue about (consistent) event naming.

@DanielRuf
Copy link
Contributor Author

Should I change the title of this PR then?

@ncoden
Copy link
Contributor

ncoden commented Feb 17, 2018

Yes ;)

@ncoden ncoden added this to the 6.5.0 milestone Feb 17, 2018
@DanielRuf DanielRuf changed the title fix: rename closed.zf.offcanvas to close.zf.offcanvas fix: consistent event name triggering in components Feb 18, 2018
@DanielRuf DanielRuf changed the title fix: consistent event name triggering in components fix: consistent event name triggering in components (offcanvas) Feb 18, 2018
@ncoden ncoden self-assigned this Feb 18, 2018
@SassNinja
Copy link
Contributor

I like the new event naming because closed.zf.offcanvas doesn't get triggered anymore while the close transition is still running and the additional close.zf.offcanvas provides more control.

However I'm a bit worried that some users might get broken projects after updating to v6.5 if they rely on closed.zf.offcanvas being triggered immediately...
I'm thinking about a way to add a console.warning to help spotting possible issues but I have no idea how to catch a misuse of the event.

@ncoden @DanielRuf what do you think? There's probably no way to throw a warning if someone is relying on closed.zf.offcanvas before the transitionend, is there?

@ncoden
Copy link
Contributor

ncoden commented Feb 19, 2018

@SassNinja I don't think, because the problem would be that they assume that the closed.zf.offcanvas event is triggered before the transition, and we do not know what makes them assuming that.

So everything we can do is a clear migration note in the release.


Edit: an other solution would be to keep closed.zf.offcanvas as it, but deprecate it with a warning message and introduce 2 new events. It's basically making the warning message always relevant by making the event always misused ;). I'm not sure it's better.

@DanielRuf
Copy link
Contributor Author

So everything we can do is a clear migration note in the release.

Definitely.

introduce 2 new events

Not sure how we could also name these.
We should stay consistent with the naming scheme.

@SassNinja
Copy link
Contributor

SassNinja commented Feb 19, 2018

Edit: an other solution would be to keep closed.zf.offcanvas as it, but deprecate it with a warning message and introduce 2 new events. It's basically making the warning message always relevant by making the event always misused ;). I'm not sure it's better.

Interesting idea what made me think about the possibility of just adding a deprecation warning in 6.5 and hold back the actual PR until 6.6

But I agree: clear migration notes is probably the best solution. I think we can expect people to read the notes before updating their projects.

Not sure how we could also name these.

Yup there is not alternative because close and closed describe it best,

@ncoden
Copy link
Contributor

ncoden commented Feb 19, 2018

@SassNinja There is no 6.6 planned as we will start working on v7 ;)

@SassNinja
Copy link
Contributor

SassNinja commented Feb 19, 2018

Alright, so forget my thought about holding it back.
Then this PR looks good from my side :)

@ncoden ncoden changed the title fix: consistent event name triggering in components (offcanvas) fix: consistent event name triggering in components Feb 26, 2018
@DanielRuf DanielRuf mentioned this pull request Mar 9, 2018
3 tasks
@DanielRuf
Copy link
Contributor Author

Currently this PR has conflicts.

Also which components do not yet use this event naming scheme (if we know it already) or should I go through all and check them?

@ncoden
Copy link
Contributor

ncoden commented Mar 17, 2018

@DanielRuf I don't have them in mind. But even with the list I'll go for manually checking all components where we change properties/attributes or wait for timeout/animation to finish anyway.

@ncoden
Copy link
Contributor

ncoden commented Mar 17, 2018

Note: v6.5 was renamed v6.6.

@DanielRuf
Copy link
Contributor Author

Resolved the conflicts.

@ncoden
Copy link
Contributor

ncoden commented Mar 24, 2018

@DanielRuf When your PR is already open, unless if you want to clean the PR, please merge develop (or master) instead of rebasing. We made comments between commits and rebasing will move commits to the bottom, making harder for later to understand what happened.

@ncoden
Copy link
Contributor

ncoden commented Mar 24, 2018

  1. Off Canvas close() fires close.zf.offcanvas event:
    Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

  2. Off Canvas close() fires closed.zf.offcanvas event:
    Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test.

Can you update tests ?

@ncoden
Copy link
Contributor

ncoden commented Mar 30, 2018

Merged develop to get full browserstack tests.
Actually I forgot that #11090 was not merged yet...

@ncoden
Copy link
Contributor

ncoden commented Mar 30, 2018

@DanielRuf Are you done with this PR ? Is there any component with single events being triggered only before or after something (timeout/transition...) ?

@DanielRuf
Copy link
Contributor Author

DanielRuf commented Mar 30, 2018

Drilldown, Offcanvas and Reveal trigger closed

Drilldown

    $elem.one(transitionend($elem), function(e){
      $elem.removeClass('is-active is-closing');
    });
        /**
         * Fires when the menu is fully closed.
         * @event Drilldown#closed
         */
    this.$element.trigger('closed.zf.drilldown');

I guess this should be in the callback of transitionend.
The reveal component already triggers it as callback of the animations.

@ncoden
Copy link
Contributor

ncoden commented Mar 30, 2018

I guess this shold be in the callback of transitionend.

True.

@DanielRuf
Copy link
Contributor Author

Updated it accordingly.

@ncoden ncoden self-requested a review March 30, 2018 22:12
- Remove unecessary event layers (`close.zf.drilldown` is already tested)
- Expect "is-closed" and "is-active" NOT to be present.
- Avoir calling `done()` several times. Call `done()` after all testes passed.
…down

When triggering "closed.zf.drilldown", the context `this` should be the component. But jQuery's `.one(...)` change it to `$elem`.
1. Retrieve datas and elements
2. Apply actions on them
3. Trigger events
@ncoden
Copy link
Contributor

ncoden commented Oct 23, 2018

@DanielRuf I took a closer look at the Drilldown test and found a bug in it, that hided a bug in the Drilldown._hideAll() method. I resolved all this and cleaned up Drilldown._hideAll(). See the commits above.

@ncoden
Copy link
Contributor

ncoden commented Oct 25, 2018

Merged develop, now tests pass. @DanielRuf are you ok with the changes above?

@DanielRuf
Copy link
Contributor Author

Merged develop, now tests pass. @DanielRuf are you ok with the changes above?

LGTM

@joeworkman
Copy link
Member

This pull request has been mentioned on Foundation Open Source Community. There might be relevant details there:

https://foundation.discourse.group/t/foundation-for-sites-v6-6-0-is-here-farout/30/1

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.

4 participants