When multiple toasts are added, only the last one expires
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- javascript, react
- Domain
- frontend
Research direction
Start by reproducing the minimal create-react-app example with several Toast components inside ToastContainer and a 1000ms duration. Inspect the Toast and ToastContainer behavior around duration and onRequestClose; done means every added toast expires, rather than only the last one, while the setDuration workaround is no longer needed.
Written by the indexing model from the issue text.
Description
Hi
First of all, great library. It makes designing according to accessibility principles so, so easy (and fun, too!).
During designing my app, I've noticed that when you add multiple Toast with duration property set to ToastContainer, only the last item gets deleted. All of them should get deleted after the set duration.
Here's a minimal working example illustrating what I'm talking about. I've created my app using create-react-app:
import React from 'react';
import {
Button,
Toast,
ToastContainer
} from '@salesforce/design-system-react';
class App extends React.Component {
state = {
toasts: []
}
addToast = () => {
const toastsCopy = [...this.state.toasts]
toastsCopy.push(
<Toast
labels={{
heading: 'Lorem ipsum'
}}
duration={1000}
onRequestClose={() => this.deleteToast(this.state.toasts.length - 1)}
/>
)
this.setState({
toasts: toastsCopy
})
}
deleteToast = id => {
const toastsCopy = [...this.state.toasts]
toastsCopy[id] = null
this.setState({
toasts: toastsCopy
})
}
render() {
return (
<div className="App">
<Button
label="Show toast"
onClick={() => this.addToast()}
/>
<ToastContainer>
{this.state.toasts}
</ToastContainer>
</div>
)
}
}
export default App;
The possible workaround is to override the default behavior - do not use the duration property, but implement deleting an item using setDuration yourself.
- Dominant language
- JavaScript
- Stars
- 994
- Forks
- 444
- Avg merge
- 3d 23h
- Merged PRs (30d)
- 44
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from salesforce/design-system-react
-
Difficulty 2/5 1-3 hours Newbie friendliness 42/100
salesforce/design-system-react#3245 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
salesforce/design-system-react#3174 · 1 comment ·
Maintainers usually reply within 1 day
-
@W-15466811 - Accessibility Issue: Year Combo Box Incorrectly Marked as Read-Only, Affecting Screen Reader UsersMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 48/100
salesforce/design-system-react#3144 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
salesforce/design-system-react#3127 · 4 comments ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
salesforce/design-system-react#3121 · 2 comments ·
Maintainers usually reply within 1 day
All issues in salesforce/design-system-react
Similar issues
-
verified whatsapp
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 6 days
-
Difficulty 1/5 Under an hour Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
salesforce/sa11y#1022 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
githubnext/gh-aw-workshop#6379 ·
Maintainers usually reply within 1 day
-
FEATURE REQUEST
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
linuxmint/cinnamon-spices-applets#9386 ·
Maintainers usually reply within 1 day