Kendo UI Angular NotificationService gives weird stacked flickering when hiding previous and showing new one.

1 Answer 61 Views
Notification
Evert Wiesenekker
Top achievements
Rank 2
Evert Wiesenekker asked on 13 Jun 2023, 03:10 PM
I am investigating other product lines, currently I am using PrimeNG, and because of some problems I am testing your Kendo UI Notification component. First my code:


    toast$ = createEffect(() =>
        this.actions$.pipe(
            ofType(CoreActions.Toast),
            filter(({message}) => !!message),
            tap(({message, messageType}) => {
                this.currentNotification?.hide();
                this.currentNotification = this.notificationService.show({
                    content: message,
                    hideAfter: 5000,
                    position: {horizontal: 'right', vertical: 'top'},
                    //animation: {type: 'fade', duration: 400}, //NOTE: Adding an animation unfortunately causes the toast to stack very shortly when using the 'hide()' function..
                    type: {style: messageType, icon: true},
                    closable: false //NOTE: If true the 'hideAfter' property is ignored
                });
            })
        ),
    {dispatch: false} // Because only an action is done, we should not redispatch (that would cause an infinite dispatch loop of toasts)
    );

As you can see, my use case is not having stacked notifications but hiding the previous one if a new one arrives. Imagine the scenario, something is saving, and you want to show 'Saving...' and when saving has finished you present 'Saved!'. Having stacked notifications is weird from this perspective. 

Now the problem is when having an animation, the hiding and showing gives weird behaviour: for a very short time, the previous message shows up below the current and is hidden (flickering). If I disable the animation it works as expected.

1 Answer, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 16 Jun 2023, 10:32 AM

Hi Evert,

Thanks for the information and code snippet.

The behaviour that is aimed can be achieved by utilizing the (in this case) currentNotification afterHide event emitter to do some custom logic after the notification has been hidden and with this approach the animation option can be used.

I've prepared a short StackBlitz demo that demonstrates the said above:

https://stackblitz.com/edit/angular-oeuacg?file=src%2Fapp%2Fapp.component.ts

I hope this information helps

Regards,
Stoyan
Progress Telerik

As of R2 2023, the default icon type will be SVG instead of Font. See this blogpost for more information.
Tags
Notification
Asked by
Evert Wiesenekker
Top achievements
Rank 2
Answers by
Stoyan
Telerik team
Share this question
or