mirror of
https://github.com/simstudioai/sim.git
synced 2026-08-31 01:11:53 +08:00
refactor: drop two more dead prop chains in the sub-block editor
`GroupedCheckboxList` declares `title` (required) and `maxHeight` and reads neither. It renders its own hardcoded copy instead — `Select PII Types to Detect` for the header and `PII types` for the field label — so a block author who sets `title` on a `grouped-checkbox-list` subBlock gets silence, and the `maxHeight = 400` default implies a scroll ceiling that is never applied. Both props go, along with the two values `sub-block.tsx` was passing. `flatTagList` was threaded through the recursive tag renderers to a dead end: declared on `NestedTagRendererProps`, inherited by `FolderContentsProps`, destructured in both, forwarded once more, and read by neither. Its real consumer is `flatTagIndexMap`, built from it at the top level and documented "Map from tag string to index for O(1) lookups" — so the array was being carried alongside its own index through arbitrary nesting depth. The top-level memo and its length checks stay; only the descent goes. Note the component's copy is PII-specific while its name and props present as generic. Renaming it is a separate call, not made here. Both removals were caught mid-flight by `tsc`: my line patterns also matched a live `flatTagList` on `KeyboardNavigationHandler` and a live `title` on `Switch`, which is exactly why the type-check runs before the commit and not after.
This commit is contained in:
-4
@@ -35,23 +35,19 @@ function SelectedCountDisplay({ noneSelected, allSelected, count }: SelectedCoun
|
||||
interface GroupedCheckboxListProps {
|
||||
blockId: string
|
||||
subBlockId: string
|
||||
title: string
|
||||
options: { label: string; id: string; group?: string }[]
|
||||
isPreview?: boolean
|
||||
subBlockValues: Record<string, any>
|
||||
disabled?: boolean
|
||||
maxHeight?: number
|
||||
}
|
||||
|
||||
export function GroupedCheckboxList({
|
||||
blockId,
|
||||
subBlockId,
|
||||
title,
|
||||
options,
|
||||
isPreview = false,
|
||||
subBlockValues,
|
||||
disabled = false,
|
||||
maxHeight = 400,
|
||||
}: GroupedCheckboxListProps) {
|
||||
const activeSearchTarget = useActiveSearchTarget()
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
+1
-6
@@ -376,7 +376,6 @@ const buildNestedTagTree = (tags: string[], blockName: string): NestedTag[] => {
|
||||
interface NestedTagRendererProps {
|
||||
nestedTag: NestedTag
|
||||
group: NestedBlockTagGroup
|
||||
flatTagList: Array<{ tag: string; group?: BlockTagGroup }>
|
||||
/** Map from tag string to index for O(1) lookups */
|
||||
flatTagIndexMap: Map<string, number>
|
||||
selectedIndex: number
|
||||
@@ -403,7 +402,6 @@ interface FolderContentsProps extends NestedTagRendererProps {
|
||||
*/
|
||||
const FolderContentsInner: React.FC<FolderContentsProps> = ({
|
||||
group,
|
||||
flatTagList,
|
||||
flatTagIndexMap,
|
||||
selectedIndex,
|
||||
setSelectedIndex,
|
||||
@@ -565,7 +563,6 @@ const FolderContents: React.FC<Omit<NestedTagRendererProps, never>> = (props) =>
|
||||
const NestedTagRenderer: React.FC<NestedTagRendererProps> = ({
|
||||
nestedTag,
|
||||
group,
|
||||
flatTagList,
|
||||
flatTagIndexMap,
|
||||
selectedIndex,
|
||||
setSelectedIndex,
|
||||
@@ -612,7 +609,6 @@ const NestedTagRenderer: React.FC<NestedTagRendererProps> = ({
|
||||
<FolderContents
|
||||
nestedTag={nestedTag}
|
||||
group={group}
|
||||
flatTagList={flatTagList}
|
||||
flatTagIndexMap={flatTagIndexMap}
|
||||
selectedIndex={selectedIndex}
|
||||
setSelectedIndex={setSelectedIndex}
|
||||
@@ -1633,9 +1629,9 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
|
||||
</PopoverAnchor>
|
||||
<KeyboardNavigationHandler
|
||||
visible={visible}
|
||||
flatTagList={flatTagList}
|
||||
selectedIndex={selectedIndex}
|
||||
setSelectedIndex={setSelectedIndex}
|
||||
flatTagList={flatTagList}
|
||||
nestedBlockTagGroups={nestedBlockTagGroups}
|
||||
handleTagSelect={handleTagSelect}
|
||||
onFolderEnter={() => {
|
||||
@@ -1720,7 +1716,6 @@ export const TagDropdown: React.FC<TagDropdownProps> = ({
|
||||
key={`${group.blockId}-${nestedTag.key}`}
|
||||
nestedTag={nestedTag}
|
||||
group={group}
|
||||
flatTagList={flatTagList}
|
||||
flatTagIndexMap={flatTagIndexMap}
|
||||
selectedIndex={selectedIndex}
|
||||
setSelectedIndex={setSelectedIndex}
|
||||
|
||||
-2
@@ -844,12 +844,10 @@ function SubBlockComponent({
|
||||
<GroupedCheckboxList
|
||||
blockId={blockId}
|
||||
subBlockId={config.id}
|
||||
title={config.title ?? ''}
|
||||
options={config.options as { label: string; id: string; group?: string }[]}
|
||||
isPreview={isPreview}
|
||||
subBlockValues={subBlockValues ?? {}}
|
||||
disabled={isDisabled}
|
||||
maxHeight={config.maxHeight}
|
||||
/>
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user