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

ebay-snackbar-dialog: open visibility is extended #2322

Open
hongjilee-1 opened this issue Nov 11, 2024 · 1 comment
Open

ebay-snackbar-dialog: open visibility is extended #2322

hongjilee-1 opened this issue Nov 11, 2024 · 1 comment

Comments

@hongjilee-1
Copy link

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

{
    _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.

Screen.Recording.2024-11-11.at.4.48.35.PM.mov
@agliga
Copy link
Contributor

agliga commented Dec 11, 2024

I believe this is desired. The reason is if any state is changed it should assume that something has changed and it should extend the open duration.

What is the usecase or problem that you are running into specifically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants