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

[Snackbar] Static properties for reason string constants #10300

Merged
merged 1 commit into from
Feb 24, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/Snackbar/Snackbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ class Snackbar extends Component {
muiTheme: PropTypes.object.isRequired,
};

static reasons = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be renamed to closeReasons?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that's really needed for something as simple as this PR is addressing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also matches the name of the argument given in the documentation..

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://www.material-ui.com/#/components/snackbar

"The reason parameter can optionally be used to control the response to onRequestClose, for example ignoring clickaway."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok - sounds good

CLICKAWAY: 'clickaway',
TIMEOUT: 'timeout'
}

componentWillMount() {
this.setState({
open: this.props.open,
Expand Down Expand Up @@ -168,7 +173,7 @@ class Snackbar extends Component {
}

if (this.props.open !== null && this.props.onRequestClose) {
this.props.onRequestClose('clickaway');
this.props.onRequestClose(Snackbar.reasons.CLICKAWAY);
} else {
this.setState({open: false});
}
Expand All @@ -182,7 +187,7 @@ class Snackbar extends Component {
clearTimeout(this.timerAutoHideId);
this.timerAutoHideId = setTimeout(() => {
if (this.props.open !== null && this.props.onRequestClose) {
this.props.onRequestClose('timeout');
this.props.onRequestClose(Snackbar.reasons.TIMEOUT);
} else {
this.setState({open: false});
}
Expand Down