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

Add "replace" method in Messages component #930

Closed
partynikko opened this issue Jun 19, 2019 · 2 comments · Fixed by #931
Closed

Add "replace" method in Messages component #930

partynikko opened this issue Jun 19, 2019 · 2 comments · Fixed by #931
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@partynikko
Copy link
Contributor

partynikko commented Jun 19, 2019

I'm submitting a ... (check one with "x")

[ ] bug report
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://forum.primefaces.org/viewforum.php?f=57

I'd like to propose a new method for the <Messages /> component to replace messages already being showed.

Imagine you are currently showing 3 messages and you then want to show 2 different messages instead. It is not possible to first do clear() and then immediately do show() because of setState being asynchronous. You can see this here:
https://codesandbox.io/s/primereact-test-1t723

Here it is with a method that works as the new messages are shown once the state change has already happened:
https://codesandbox.io/s/primereact-test-9uh86

I'll create a PR for it and hope you will approve.

partynikko added a commit to partynikko/primereact that referenced this issue Jun 19, 2019
By first clearing messages with setState and then
provide a callback to set new messages we ensure
that the state has been updated before we try
to add new messages that are to replace existing
ones.

Fixes primefaces#930
@mertsincan
Copy link
Member

You're right! Thanks a lot for the PR ;)

@mertsincan mertsincan self-assigned this Jun 20, 2019
@mertsincan mertsincan added the Type: New Feature Issue contains a new feature or new component request label Jun 20, 2019
@mertsincan mertsincan changed the title Replace messages in Messages component Add "replace" method in Messages component Jun 20, 2019
@mertsincan mertsincan added this to the 3.1.5 milestone Jun 20, 2019
mertsincan added a commit that referenced this issue Jun 20, 2019
Fixed #930 - Add method for replacing messages of Message component
mertsincan added a commit that referenced this issue Jun 20, 2019
@partynikko
Copy link
Contributor Author

Thanks for accepting! ☺️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants