diff --git a/app/packages/state/src/recoil/sidebar.test.ts b/app/packages/state/src/recoil/sidebar.test.ts index a69542c689..2aa826fc9b 100644 --- a/app/packages/state/src/recoil/sidebar.test.ts +++ b/app/packages/state/src/recoil/sidebar.test.ts @@ -2,8 +2,8 @@ import { describe, expect, it, vi } from "vitest"; vi.mock("recoil"); vi.mock("recoil-relay"); -import { Field } from "@fiftyone/utilities"; -import { setMockAtoms, TestSelector } from "../../../../__mocks__/recoil"; +import { DICT_FIELD, Field, STRING_FIELD } from "@fiftyone/utilities"; +import { TestSelector, setMockAtoms } from "../../../../__mocks__/recoil"; import * as sidebar from "./sidebar"; const mockFields = { @@ -566,3 +566,23 @@ describe("hiddenNoneGroups selector", () => { expect(testHiddenNoneGroups()).toStrictEqual(present); }); }); + +describe("collapsedPaths resolution", () => { + it("does not add valid list fields (i.e. with a primitive subfield)", () => { + setMockAtoms({ + field: (path) => + path === "dict_list" + ? { subfield: DICT_FIELD } + : { subfield: STRING_FIELD }, + fieldPaths: ({ ftype }) => + ftype === DICT_FIELD ? [] : ["dict_list", "string_list"], + fields: () => [], + }); + + const collapsed = >( + (sidebar.collapsedPaths) + ); + + expect(collapsed()).toStrictEqual(new Set(["dict_list"])); + }); +}); diff --git a/app/packages/state/src/recoil/sidebar.ts b/app/packages/state/src/recoil/sidebar.ts index d68c42865e..d92783dbdd 100644 --- a/app/packages/state/src/recoil/sidebar.ts +++ b/app/packages/state/src/recoil/sidebar.ts @@ -20,6 +20,7 @@ import { LABELS_PATH, LABEL_DOC_TYPES, LIST_FIELD, + UNSUPPORTED_FILTER_TYPES, VALID_LABEL_TYPES, VALID_PRIMITIVE_TYPES, withPath, @@ -292,7 +293,6 @@ export const resolveGroups = ( "other", fieldsMatcher(frameFields, () => true, present, "frames.") ); - return groups; }; @@ -761,11 +761,16 @@ export const isDisabledFilterPath = selectorFamily({ get(disabledFilterPaths).has(path), }); -const collapsedPaths = selector>({ +export const collapsedPaths = selector>({ key: "collapsedPaths", get: ({ get }) => { let paths = [...get(fieldPaths({ ftype: DICT_FIELD }))]; - paths = [...paths, ...get(fieldPaths({ ftype: LIST_FIELD }))]; + paths = [ + ...paths, + ...get(fieldPaths({ ftype: LIST_FIELD })).filter((path) => + UNSUPPORTED_FILTER_TYPES.includes(get(field(path)).subfield) + ), + ]; for (const { fields: fieldsData, name: prefix } of get( fields({ ftype: EMBEDDED_DOCUMENT_FIELD, space: State.SPACE.SAMPLE }) @@ -877,6 +882,7 @@ export const groupShown = selectorFamily< if (["tags"].includes(group)) { return null; } + return ( !data.paths.length || !data.paths.every((path) => get(collapsedPaths).has(path))