Skip to content

Commit

Permalink
Toast close on click #41
Browse files Browse the repository at this point in the history
  • Loading branch information
serayuzgur committed Jan 23, 2017
1 parent 2805598 commit 9affead
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Refactored
- Now supports multi-line #45
* TextInput onChange-focus bug fixed.
* Toast close on click

## 1.1.18
* upgrade robe-react-commons library.
Expand Down
20 changes: 16 additions & 4 deletions src/toast/Toast.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@ class Toast extends ShallowComponent {
}, TIMEOUTS.REMOVE);
}, toast.timeOut);
}
closeOnClick(e) {
let id = e.target.getAttribute("id");
let element = e.target;
if (!id) {
id = e.target.parentNode.getAttribute("id");
element = e.target.parentNode;
}
ClassName.replace(element, "toast-item-open", "toast-item-close");
let arr = this.state.listToast.slice(0);
Arrays.removeByKey(arr, "id", { id });
this.setState({ listToast: arr });
}

/**
* Toast.info(message, title, timeOut, callback)
Expand All @@ -188,7 +200,7 @@ class Toast extends ShallowComponent {
message: message,
title: title,
timeOut: timeOut || this.props.timeOut,
onClick: onClick
onClick: onClick || this.closeOnClick
});
}

Expand All @@ -206,7 +218,7 @@ class Toast extends ShallowComponent {
message: message,
title: title,
timeOut: timeOut || this.props.timeOut,
onClick: onClick
onClick: onClick || this.closeOnClick
});
}

Expand All @@ -224,7 +236,7 @@ class Toast extends ShallowComponent {
message: message,
title: title,
timeOut: timeOut || this.props.timeOut,
onClick: onClick
onClick: onClick || this.closeOnClick
});
}

Expand All @@ -242,7 +254,7 @@ class Toast extends ShallowComponent {
message: message,
title: title,
timeOut: timeOut || this.props.timeOut,
onClick: onClick
onClick: onClick || this.closeOnClick
});
}
static configuration(props) {
Expand Down

0 comments on commit 9affead

Please sign in to comment.