App Loses Focus if Chrome Show Notifications Dialog Is Closed With X2019 Community Moderator ElectionChrome desktop notification exampleRepeated call to webkitNotifications.requestPermission() doesn't show permission request in chromeFancyBox close button shows four buttons in chromeIs there any way to insert action buttons in notification in Google ChromeJavascript window.print() in chrome, closing new window or tab instead of cancelling print leaves javascript blocked in parent windowHow to sent notifications to many user with chrome desktop notificationCan't detect when user close a Chrome alert dialogChrome Notification API (for Extensions!) How to Re-enable Once Blocked?Google Chrome Extension Notification API Permission LevelChrome browser version 72.0.3626.96 bug triggering <input type=“file”> click (file select dialog) from javascript function

Why aren't there more Gauls like Obelix?

When a wind turbine does not produce enough electricity how does the power company compensate for the loss?

Is a piano played in the same way as a harmonium?

Trig Subsitution When There's No Square Root

Does an unused member variable take up memory?

Specifying a starting column with colortbl package and xcolor

How to resolve: Reviewer #1 says remove section X vs. Reviewer #2 says expand section X

Can we track matter through time by looking at different depths in space?

Was it really inappropriate to write a pull request for the company I interviewed with?

What do *foreign films* mean for an American?

Which classes are needed to have access to every spell in the PHB?

Virginia employer terminated employee and wants signing bonus returned

What's the 'present simple' form of the word "нашла́" in 3rd person singular female?

When Schnorr signatures are part of Bitcoin will it be possible validate each block with only one signature validation?

Giving a career talk in my old university, how prominently should I tell students my salary?

Having the player face themselves after the mid-game

What can I do if someone tampers with my SSH public key?

Why restrict private health insurance?

Conservation of Mass and Energy

Why is there an extra space when I type "ls" in the Desktop directory?

Has a sovereign Communist government ever run, and conceded loss, on a fair election?

For which categories of spectra is there an explicit description of the fibrant objects via lifting properties?

What would be the most expensive material to an intergalactic society?

Why does cron require MTA for logging?



App Loses Focus if Chrome Show Notifications Dialog Is Closed With X



2019 Community Moderator ElectionChrome desktop notification exampleRepeated call to webkitNotifications.requestPermission() doesn't show permission request in chromeFancyBox close button shows four buttons in chromeIs there any way to insert action buttons in notification in Google ChromeJavascript window.print() in chrome, closing new window or tab instead of cancelling print leaves javascript blocked in parent windowHow to sent notifications to many user with chrome desktop notificationCan't detect when user close a Chrome alert dialogChrome Notification API (for Extensions!) How to Re-enable Once Blocked?Google Chrome Extension Notification API Permission LevelChrome browser version 72.0.3626.96 bug triggering <input type=“file”> click (file select dialog) from javascript function










0















I have a button that allows users to turn on notifications

(no annoying pop-up at an unexpected time)



<span *ngIf="!showButton">
<div class="notificationsMsg">notificationMessage</div>
</span>
<span *ngIf="showButton">
<button mat-stroked-button
id="sendButton"
(click)="enableNotifications()">Enable Notifications</button>
</span>


When the button is clicked

I display the Chrome Allow Notifications dialog

And respond to the user's action

Then hide the button (you cannot show the dialog twice) and show a message



enter image description here



If the user selects BLOCK or ALLOW

Everything works as expected

Button Hidden, Message shown



If the user closes the dialog with the X

My code fires, but the page is not updated until you manually click on it



Is there something I could do to in my code give the page focus again to hide the button and show the message?



// the button was clicked
enableNotifications()

Notification.requestPermission(perm =>
if (perm === 'granted')
console.log('allow clicked');
this.notificationMessage = 'Woo Hoo';
else if (['default', 'denied'].indexOf(perm) > -1)
console.log('block clicked or dialog closed');
this.notificationMessage = 'DENIED';

this.showButton = false;
);



Chrome Version 72.0.3626.121 (Official Build) (64-bit)










share|improve this question






















  • Can you explain better My code fires, but the page is not updated until you manually click on it? Which code? And what should be updated?

    – Massimiliano Sartoretto
    Mar 6 at 15:22











  • The variable used to show/hide the message and button is set, but they are not shown & hidden until I click on the page manually.

    – Mathias
    Mar 6 at 15:36















0















I have a button that allows users to turn on notifications

(no annoying pop-up at an unexpected time)



<span *ngIf="!showButton">
<div class="notificationsMsg">notificationMessage</div>
</span>
<span *ngIf="showButton">
<button mat-stroked-button
id="sendButton"
(click)="enableNotifications()">Enable Notifications</button>
</span>


When the button is clicked

I display the Chrome Allow Notifications dialog

And respond to the user's action

Then hide the button (you cannot show the dialog twice) and show a message



enter image description here



If the user selects BLOCK or ALLOW

Everything works as expected

Button Hidden, Message shown



If the user closes the dialog with the X

My code fires, but the page is not updated until you manually click on it



Is there something I could do to in my code give the page focus again to hide the button and show the message?



// the button was clicked
enableNotifications()

Notification.requestPermission(perm =>
if (perm === 'granted')
console.log('allow clicked');
this.notificationMessage = 'Woo Hoo';
else if (['default', 'denied'].indexOf(perm) > -1)
console.log('block clicked or dialog closed');
this.notificationMessage = 'DENIED';

this.showButton = false;
);



Chrome Version 72.0.3626.121 (Official Build) (64-bit)










share|improve this question






















  • Can you explain better My code fires, but the page is not updated until you manually click on it? Which code? And what should be updated?

    – Massimiliano Sartoretto
    Mar 6 at 15:22











  • The variable used to show/hide the message and button is set, but they are not shown & hidden until I click on the page manually.

    – Mathias
    Mar 6 at 15:36













0












0








0








I have a button that allows users to turn on notifications

(no annoying pop-up at an unexpected time)



<span *ngIf="!showButton">
<div class="notificationsMsg">notificationMessage</div>
</span>
<span *ngIf="showButton">
<button mat-stroked-button
id="sendButton"
(click)="enableNotifications()">Enable Notifications</button>
</span>


When the button is clicked

I display the Chrome Allow Notifications dialog

And respond to the user's action

Then hide the button (you cannot show the dialog twice) and show a message



enter image description here



If the user selects BLOCK or ALLOW

Everything works as expected

Button Hidden, Message shown



If the user closes the dialog with the X

My code fires, but the page is not updated until you manually click on it



Is there something I could do to in my code give the page focus again to hide the button and show the message?



// the button was clicked
enableNotifications()

Notification.requestPermission(perm =>
if (perm === 'granted')
console.log('allow clicked');
this.notificationMessage = 'Woo Hoo';
else if (['default', 'denied'].indexOf(perm) > -1)
console.log('block clicked or dialog closed');
this.notificationMessage = 'DENIED';

this.showButton = false;
);



Chrome Version 72.0.3626.121 (Official Build) (64-bit)










share|improve this question














I have a button that allows users to turn on notifications

(no annoying pop-up at an unexpected time)



<span *ngIf="!showButton">
<div class="notificationsMsg">notificationMessage</div>
</span>
<span *ngIf="showButton">
<button mat-stroked-button
id="sendButton"
(click)="enableNotifications()">Enable Notifications</button>
</span>


When the button is clicked

I display the Chrome Allow Notifications dialog

And respond to the user's action

Then hide the button (you cannot show the dialog twice) and show a message



enter image description here



If the user selects BLOCK or ALLOW

Everything works as expected

Button Hidden, Message shown



If the user closes the dialog with the X

My code fires, but the page is not updated until you manually click on it



Is there something I could do to in my code give the page focus again to hide the button and show the message?



// the button was clicked
enableNotifications()

Notification.requestPermission(perm =>
if (perm === 'granted')
console.log('allow clicked');
this.notificationMessage = 'Woo Hoo';
else if (['default', 'denied'].indexOf(perm) > -1)
console.log('block clicked or dialog closed');
this.notificationMessage = 'DENIED';

this.showButton = false;
);



Chrome Version 72.0.3626.121 (Official Build) (64-bit)







angular google-chrome






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 6 at 14:39









MathiasMathias

8311615




8311615












  • Can you explain better My code fires, but the page is not updated until you manually click on it? Which code? And what should be updated?

    – Massimiliano Sartoretto
    Mar 6 at 15:22











  • The variable used to show/hide the message and button is set, but they are not shown & hidden until I click on the page manually.

    – Mathias
    Mar 6 at 15:36

















  • Can you explain better My code fires, but the page is not updated until you manually click on it? Which code? And what should be updated?

    – Massimiliano Sartoretto
    Mar 6 at 15:22











  • The variable used to show/hide the message and button is set, but they are not shown & hidden until I click on the page manually.

    – Mathias
    Mar 6 at 15:36
















Can you explain better My code fires, but the page is not updated until you manually click on it? Which code? And what should be updated?

– Massimiliano Sartoretto
Mar 6 at 15:22





Can you explain better My code fires, but the page is not updated until you manually click on it? Which code? And what should be updated?

– Massimiliano Sartoretto
Mar 6 at 15:22













The variable used to show/hide the message and button is set, but they are not shown & hidden until I click on the page manually.

– Mathias
Mar 6 at 15:36





The variable used to show/hide the message and button is set, but they are not shown & hidden until I click on the page manually.

– Mathias
Mar 6 at 15:36












1 Answer
1






active

oldest

votes


















1














You must update your component variables within Angular zone.



import Component, OnInit, NgZone from '@angular/core';

@Component(
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
)
export class AppComponent implements OnInit
name = 'Angular';
notificationMessage = '';
showButton: boolean;

constructor(private zone: NgZone)

ngOnInit()
Notification.requestPermission(perm =>
if (perm === 'granted')
console.log('allow clicked');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Woo Hoo';
);

else if (['default', 'denied'].indexOf(perm) > -1)
console.log('block clicked or dialog closed');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Denied';
);


);




Live Demo






share|improve this answer

























  • Thanks! Somehow I have never known about Angular zone. So much to learn.

    – Mathias
    Mar 6 at 15:44











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025678%2fapp-loses-focus-if-chrome-show-notifications-dialog-is-closed-with-x%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














You must update your component variables within Angular zone.



import Component, OnInit, NgZone from '@angular/core';

@Component(
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
)
export class AppComponent implements OnInit
name = 'Angular';
notificationMessage = '';
showButton: boolean;

constructor(private zone: NgZone)

ngOnInit()
Notification.requestPermission(perm =>
if (perm === 'granted')
console.log('allow clicked');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Woo Hoo';
);

else if (['default', 'denied'].indexOf(perm) > -1)
console.log('block clicked or dialog closed');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Denied';
);


);




Live Demo






share|improve this answer

























  • Thanks! Somehow I have never known about Angular zone. So much to learn.

    – Mathias
    Mar 6 at 15:44
















1














You must update your component variables within Angular zone.



import Component, OnInit, NgZone from '@angular/core';

@Component(
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
)
export class AppComponent implements OnInit
name = 'Angular';
notificationMessage = '';
showButton: boolean;

constructor(private zone: NgZone)

ngOnInit()
Notification.requestPermission(perm =>
if (perm === 'granted')
console.log('allow clicked');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Woo Hoo';
);

else if (['default', 'denied'].indexOf(perm) > -1)
console.log('block clicked or dialog closed');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Denied';
);


);




Live Demo






share|improve this answer

























  • Thanks! Somehow I have never known about Angular zone. So much to learn.

    – Mathias
    Mar 6 at 15:44














1












1








1







You must update your component variables within Angular zone.



import Component, OnInit, NgZone from '@angular/core';

@Component(
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
)
export class AppComponent implements OnInit
name = 'Angular';
notificationMessage = '';
showButton: boolean;

constructor(private zone: NgZone)

ngOnInit()
Notification.requestPermission(perm =>
if (perm === 'granted')
console.log('allow clicked');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Woo Hoo';
);

else if (['default', 'denied'].indexOf(perm) > -1)
console.log('block clicked or dialog closed');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Denied';
);


);




Live Demo






share|improve this answer















You must update your component variables within Angular zone.



import Component, OnInit, NgZone from '@angular/core';

@Component(
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
)
export class AppComponent implements OnInit
name = 'Angular';
notificationMessage = '';
showButton: boolean;

constructor(private zone: NgZone)

ngOnInit()
Notification.requestPermission(perm =>
if (perm === 'granted')
console.log('allow clicked');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Woo Hoo';
);

else if (['default', 'denied'].indexOf(perm) > -1)
console.log('block clicked or dialog closed');
this.zone.run(() =>
this.showButton = false;
this.notificationMessage = 'Denied';
);


);




Live Demo







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 6 at 15:40

























answered Mar 6 at 15:32









Umut EsenUmut Esen

8371128




8371128












  • Thanks! Somehow I have never known about Angular zone. So much to learn.

    – Mathias
    Mar 6 at 15:44


















  • Thanks! Somehow I have never known about Angular zone. So much to learn.

    – Mathias
    Mar 6 at 15:44

















Thanks! Somehow I have never known about Angular zone. So much to learn.

– Mathias
Mar 6 at 15:44






Thanks! Somehow I have never known about Angular zone. So much to learn.

– Mathias
Mar 6 at 15:44




















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55025678%2fapp-loses-focus-if-chrome-show-notifications-dialog-is-closed-with-x%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко