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

Toast - Clear and then show doesn't clear existing messages #2668

Closed
omerts opened this issue Mar 2, 2022 · 3 comments · Fixed by #2932
Closed

Toast - Clear and then show doesn't clear existing messages #2668

omerts opened this issue Mar 2, 2022 · 3 comments · Fixed by #2932
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@omerts
Copy link

omerts commented Mar 2, 2022

I'm submitting a ...

[ X] bug report

Codesandbox Case (Bug Reports)
https://codesandbox.io/embed/primereact-test-forked-kf580b?fontsize=14&hidenavigation=1&theme=dark]

Current behavior

Use Toast's clear method and then show, doesn't clear existing messages, as setState is an async operation, so show is using a stale messages state, and thus returns old messages.

Expected behavior
Messages should be cleared up clear regardless of show being used afterwards.

Minimal reproduction of the problem with instructions
See codesandbox demo

  • PrimeReact version:
    6.0.1

  • Language: all

@melloware
Copy link
Member

Also I know Messages has a replace function which maybe you can add which will call clear and add the new message in one method call as a bonus?

@yigitfindikli yigitfindikli added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Mar 31, 2022
@yigitfindikli yigitfindikli added this to the 8.0.0 milestone Mar 31, 2022
@melloware melloware modified the milestones: 8.0.0.Final, 8.0.0-rc.2 Apr 10, 2022
@melloware
Copy link
Member

This is actually fixed in 8.0.0-rc1 now that it has been switched to Hooks.
See: https://codesandbox.io/s/primereact-test-forked-5zuel3

@melloware melloware added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Apr 10, 2022
melloware added a commit to melloware/primereact that referenced this issue May 25, 2022
@melloware melloware modified the milestones: 8.0.0-rc.2, 8.2.0 May 25, 2022
@melloware
Copy link
Member

OK I have added a replace method which also accomplishes this in 1 line without calling clear then show

melloware added a commit to melloware/primereact that referenced this issue May 25, 2022
@melloware melloware assigned melloware and unassigned mcandu May 25, 2022
@melloware melloware added Type: Bug Issue contains a defect related to a specific component. and removed Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add labels May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a defect related to a specific component.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants