cvat-ai / cvat

Annotate better with CVAT, the industry-leading data engine for machine learning. Used and trusted by teams at any scale, for data of any scale.
https://cvat.ai
MIT License
12.58k stars 3k forks source link

Specific shortcut settings are not being saved after refreshing page #8440

Open likelikeslike opened 1 month ago

likelikeslike commented 1 month ago

Actions before raising this issue

Steps to Reproduce

  1. Go to settings and select shortcuts tab.
  2. Change the shortcut for Switch label to xxx under the Objects sidebar to a new key combination.
  3. Refresh the page.
  4. The shortcut is resettled to default.

Expected Behavior

After saving this change, the shortcut works and remains active even after refreshing the page. I have tested some shortcuts under General and Annotation page, and they function properly without resetting to the default settings.

Possible Solution

Should the same logic for shortcuts under General be applied here as well?

Context

No response

Environment

Self-hosted CVAT (v2.18.0) with customized permission controls, particularly for data exportation.
bsekachev commented 1 month ago

Reproducable, thanks

luukvnes commented 1 month ago

Can be fixed by adding this line sequences: keyMap[key]?.sequences ?? updatedComponentShortcuts[key].sequences, to label-list.tsx in the below useEffect

    useEffect(() => {
        const updatedComponentShortcuts = JSON.parse(JSON.stringify(componentShortcuts));
        for (const [index, labelID] of Object.entries(keyToLabelMapping)) {
            if (labelID) {
                const labelName = labels.find((label: any) => label.id === labelID)?.name;
                const key = makeKey(+index);
                updatedComponentShortcuts[key] = {
                    ...updatedComponentShortcuts[key],
                    nonActive: false,
                    name: `Switch label to ${labelName}`,
                    description: `Changes the label to ${labelName} for the activated
                        object or for the next drawn object if no objects are activated`,
                    sequences: keyMap[key]?.sequences ?? updatedComponentShortcuts[key].sequences,
                };
            }
        }

        registerComponentShortcuts(updatedComponentShortcuts);
    }, [labels]);