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

failure to get 'open_files' callback on initial double click after page refresh when using +2 browsers in the same page #193

Open
eilyaamin opened this issue Jul 20, 2023 · 2 comments

Comments

@eilyaamin
Copy link

scrnli-7-20-2023-12-40-13-pm_q7PLD7KD.webm
@erenertas
Copy link

+1. When I render filebrowser component more than 1, chonky's action handler doesn't fires open_files and mouse_click: double events. Basically it couldn't handle double clicks. Only bottom component fires double click events. When clicking randomly on any file browser, somehow the double click throw event can pass from the bottom component to another random component. But in the end, only one rendered component can handle double clicks. That's why I developed my action handler by adapting it to a single mouse click. This is a critical bug that needs to be resolved.

@divad1196
Copy link

Hi, I am having the same issue.

For the moment, I fixed it by keeping track of the "single" clicks events myself (only works because the single-click event doesn't have a major effect on my app):

function getActionHandler() {
    let lastSingleClick = Date.now();
    let doubleClickDelay = 300;

    const handleAction = (data, setCurrentFolder) => {
        if (data.id === ChonkyActions.MouseClickFile.id) {
            let file = data.payload.file;
            if (data.payload.clickType === "double") {
                setCurrentFolder(file.id);
            } else {
                let now = Date.now();
                if(now - lastSingleClick < doubleClickDelay) {
                    setCurrentFolder(file.id);
                }
                lastSingleClick = now;
            }
        }
    };

    return handleAction;
}

and I use it this way in my component:

const handleAction = React.useMemo(getActionHandler, []);

This won't prevent the "single" click event to be fired so any action triggered by the single click will apply.
Hope it helps in some of your cases.

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

No branches or pull requests

3 participants