When setting input open state for the <ebay-snackbar-dialog open=state.isOpen /> from a separate button that toggles isOpen true/false, as long as the snackbar is open and visible, the click to change isOpen=false results in the snackbar setTimeout being extended.
{
_setupTimeout() {
// This timer will be extended again by 6s as long as its open and another update occurs
if (this.state.open !== false) {
this.timeout = setTimeout(() => {
this.state.open = false;
}, DEFAULT_TIMEOUT_LENGTH);
}
}
onInput(input: Input) {
this.state = { open: input.open || this.state.open || false };
}
onMount() {
this._setupTimeout();
}
onUpdate() {
this._setupTimeout(); // <-- 1. any state changes above will result in this being re-invoked
}
}
Expectation:
Toggle isOpen to true, wait 5 seconds, toggle isOpen to false, the snackbar should close 1 second later.
Occurs
Toggle isOpen to true, wait 5 seconds, toggle isOpen to false, the snackbar closes 6 seconds later.
Screenshots
The first click waits 5 seconds and then clicks close (snackbar is extended).
The second click waits 6 seconds and the setTimeout causes state to be closed.
Bug Report
eBayUI Version: 14.3.0
Description
When setting input open state for the
<ebay-snackbar-dialog open=state.isOpen />
from a separate button that toggles isOpen true/false, as long as the snackbar is open and visible, the click to change isOpen=false results in the snackbar setTimeout being extended.For every onUpdate on this snackbar, as long as the previous state was open it will set another setTimeout. https://github.com/eBay/ebayui-core/blob/master/src/components/ebay-snackbar-dialog/component.ts#L29-L35
Expectation: Toggle isOpen to true, wait 5 seconds, toggle isOpen to false, the snackbar should close 1 second later.
Occurs Toggle isOpen to true, wait 5 seconds, toggle isOpen to false, the snackbar closes 6 seconds later.
Screenshots
The first click waits 5 seconds and then clicks close (snackbar is extended). The second click waits 6 seconds and the setTimeout causes state to be closed.
https://github.com/user-attachments/assets/843182c7-cdd1-4aac-8c8e-78c705634916