Skip to content

fix(alert): dismissed event not emitted if dismissed-event-countdown is listened (closes #2967) #2968

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

Closed
wants to merge 8 commits into from

Conversation

DM2489
Copy link
Contributor

@DM2489 DM2489 commented Mar 31, 2019

Description of Pull Request:

This should fix the issue with the incorrect events being emitted when a dismissable alert is being counted down.

Closes #2967.

PR checklist:

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Enhancement to an existing feature
  • ARIA accessibility
  • Documentation update
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

If yes, please describe the impact:

The PR fulfills these requirements:

  • It's submitted to the dev branch, not the master branch
  • When resolving a specific issue, it's referenced in the PR's title (i.e.
    fixes #xxxx[,#xxxx], where "xxxx" is the issue number)
  • The PR should address only one issue or feature. If adding multiple features or fixing a bug
    and adding a new feature, break them into separate PRs if at all possible.
  • PR titles should following the
    Conventional Commits naming convention (i.e.
    "fix(alert): not alerting during SSR render", "docs(badge): Updated pill examples, fix typos",
    "chore: fix typo in docs", etc). This is very important, as the CHANGELOG is generated
    from these messages.

If new features/enhancement/fixes are added or changed:

  • Includes documentation updates (including updating the component's package.json for slot and
    event changes)
  • New/updated tests are included and passing (if required)
  • Existing test suites are passing
  • The changes have not impacted the functionality of other components or directives
  • ARIA Accessibility has been taken into consideration (does it affect screen reader users or
    keyboard only users? clickable items should be in the tab index, etc)

If adding a new feature, or changing the functionality of an existing feature, the PR's
description above includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a
    suggestion issue first and wait for approval before working on it)

@codecov
Copy link

codecov bot commented Mar 31, 2019

Codecov Report

❗ No coverage uploaded for pull request base (dev@cbf24c3). Click here to learn what that means.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff           @@
##             dev    #2968   +/-   ##
======================================
  Coverage       ?   92.06%           
======================================
  Files          ?      205           
  Lines          ?     3251           
  Branches       ?      960           
======================================
  Hits           ?     2993           
  Misses         ?      190           
  Partials       ?       68
Impacted Files Coverage Δ
src/components/alert/alert.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cbf24c3...b4cea65. Read the comment docs.

@@ -63,9 +63,10 @@ export default {
dismiss() {
this.clearCounter()
if (typeof this.show === 'number') {
this.$emit('dismiss-count-down', 0)
Copy link
Member

Choose a reason for hiding this comment

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

If someone clicks the dismiss close button, the countdown timer value will not be emitted as 0 (and some users rely on this event emitting 0 when dismissed early.

Copy link
Member

@tmorehouse tmorehouse Mar 31, 2019

Choose a reason for hiding this comment

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

you should check first if this.dismissCountDown is greater than 0, and if so, emit 'dismiss-count-down with a value of 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's the original code - I've just added an extra event to emit dismissed.

I do agree though, but there is no this.dismissCountDown - it's a local variable in the showChanges method.

I can add another parseInt on this.show and then if it's greater than 0, emit the event?

Copy link
Member

Choose a reason for hiding this comment

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

Ah right... in the revamped code I was working on for BAlert, I was switching to setTimeout from setInterval (to simplify the code/logic) and storing the dismissCountDown value in data().

Maybe at line 95 where we defined the variable dismissCountDown, it should be stored in data, and any decrement would be done on the this.dismissCountDown.

Copy link
Member

Choose a reason for hiding this comment

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

Or, I can update the BAlert code with the new code I was getting ready to implement and see if it fixes the original issue (as it also fixes a few other issues with BAlert)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tmorehouse I'm not fussy - I just need to see this fixed as I'm planning on using it heavily.

@jacobmllr95 jacobmllr95 changed the title fix(alert): 'dismissed' event not emitted if 'dismissed-event-countdown' is listened #2967 fix(alert): dismissed event not emitted if dismissed-event-countdown is listened (closes #2967) Mar 31, 2019
@@ -63,9 +63,13 @@ export default {
dismiss() {
this.clearCounter()
if (typeof this.show === 'number') {
this.$emit('dismiss-count-down', 0)
if (parseInt(this.show) || 1) > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

There is a closing bracket missing.

Copy link
Member

Choose a reason for hiding this comment

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

This is also assuming that the user is v-modeling the show prop, which is not always the case.

It would be better to check the value of this.dismissCountDown to see if it is greater than 0.

Copy link
Contributor Author

@DM2489 DM2489 Mar 31, 2019

Choose a reason for hiding this comment

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

@tmorehouse Well i tried... Still not seeing any reference to this.dismissCountDown and the only reference to dismissCountDown in the entire file is a local variable in the showChanged() method, as per my previous comment.

@DM2489
Copy link
Contributor Author

DM2489 commented Mar 31, 2019

Closing in favour of #2969

@DM2489 DM2489 closed this Mar 31, 2019
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.

BAlert - 'dismissed' event not emitted if 'dismissed-event-countdown' is listened
3 participants