-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
onDismiss() not functioning #52
Comments
Thanks for the issue, @tlwirtz. Should be fixed in 1.0.3. |
@lemonmade This is not fixed (at least in 1.9.1). |
Hi @inoks, I checked out v1.9.1 and tried using the code sample you provided and it is working as expected. Are there other errors happening? |
@tmlayton Oh, yes that's works, sorry for misleading you. |
@inoks makes sense, although we avoid managing state within the components and leave it up to the consumer to handle. |
Hi @inoks @tmlayton, I am facing a similar problem. There is no internal way to hide the banner when dismiss button is clicked. You mentioned something about creating external hide/display state. Can you explain how that can be done as this is my first time working with Polaris components and i have had no luck trying to hide the banner. |
Hey @lakshyads, in the code that renders the class PageWithDismissableBanner extends React.Component {
constructor(props) {
super(props);
this.state = {
showBanner: true,
}
}
handleBannerDismiss = () => {
this.setState({showBanner: false})
}
render() {
const {showBanner} = this.state;
const dismissableBannerMarkup = showBanner ? (
<Banner title="Your banner title" onDismiss={this.handleBannerDismiss}>
<p>Your banner content</p>
</Banner>
) : null
return (
<Page title="Your page title">
{dismissableBannerMarkup}
{your other page markup}
</Page>
);
}
} |
Issue summary
When using the Banner component and passing a function into the
onDismiss
prop it doesn't appear that the callback ever fires when the dismissal button is pressed.Expected behavior
Expected the callback to fire when dismissal button is pressed.
Actual behavior
Clicking the dismissal button does not trigger the callback.
Steps to Reproduce the Problem
This is how I'm rendering the Banner. The component displays properly onscreen.
Specifications
NOTE: This repo is only used for reporting issues and new feature requests. We are not accepting pull requests at this point in time.
The text was updated successfully, but these errors were encountered: