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

Growl: messages appears again on any change state #196

Closed
RushPVA opened this issue Dec 1, 2017 · 4 comments
Closed

Growl: messages appears again on any change state #196

RushPVA opened this issue Dec 1, 2017 · 4 comments
Assignees
Labels
Type: Bug Issue contains a defect related to a specific component.
Milestone

Comments

@RushPVA
Copy link

RushPVA commented Dec 1, 2017

Example(modified demo growl page)

export class MessagesDemo extends Component {

    constructor() {
        super();
        this.state = {messages: null, test: ''};
        this.showSuccess = this.showSuccess.bind(this);

    }

    showSuccess() {
        this.setState({messages:[{severity:'success', summary:'Success Message', detail:'Order submitted'}]});
    }

   
    render() {
        return(
            <div className="ui-g">
                <div className="ui-g-12">
                    <div className="card">
                        <h1>Growl</h1>
                        <Growl value={this.state.messages} />
           
                        <Button onClick={this.showSuccess} label="Success" style={{width:'100px'}} className="green-btn" />

                    </div>

                    <div className="card">
                        <h1>Invalid Field</h1>
                        <span className="md-inputfield">
                            <InputText className="ng-dirty ng-invalid" placeholder="Invalid" onInput={(e) => this.setState({test: e.target.value})}/>
                            <div className="ui-message ui-messages-error ui-corner-all">
                                This field is required
                            </div>
                        </span>
                    </div>
                </div>
            </div>
        )
    }
}

To reproduce issue click 'Success' button, then try to change input. On every input change message appears again.

@RushPVA
Copy link
Author

RushPVA commented Dec 1, 2017

i suppose the same behaviour will be in Messages component

@RushPVA
Copy link
Author

RushPVA commented Dec 1, 2017

dirty workaround:
componentDidUpdate() {
this.state.messages = [];
}

@cagataycivici cagataycivici self-assigned this Dec 2, 2017
@cagataycivici cagataycivici added this to the 1.2.1 milestone Dec 2, 2017
@cagataycivici
Copy link
Member

cagataycivici commented Dec 2, 2017

I've rewritten Growl with a different approach which is common in React ecosystem;

#202

It also fixes this issue.

Will also do it for messages.

@cagataycivici cagataycivici added the Type: Bug Issue contains a defect related to a specific component. label Dec 2, 2017
@RushPVA
Copy link
Author

RushPVA commented Dec 3, 2017

Well done!!!
P.S. on my projects i use both Angular and React and your library(primeng and primereact) makes my life easier. Thank you very much.

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

No branches or pull requests

2 participants