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

Prevent None Controls From Adding Rows To Inspector. #6016

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
ArrayControlDescription,
BaseControlDescription,
ControlDescription,
NoneControlDescription,
ObjectControlDescription,
RegularControlDescription,
TupleControlDescription,
Expand Down Expand Up @@ -934,6 +935,11 @@ const ArrayControlItem = React.memo((props: ArrayControlItemProps) => {
const contextMenuItems = Utils.stripNulls([addOnUnsetValues([index], propMetadata.onUnsetValues)])

const contextMenuId = `context-menu-for-${PP.toString(propPathWithIndex)}`

if (controlDescription.propertyControl.control === 'none') {
return null
}

return (
<InspectorContextMenuWrapper
id={contextMenuId}
Expand Down Expand Up @@ -1082,6 +1088,12 @@ const TupleControlItem = React.memo((props: TupleControlItemProps) => {
)
const contextMenuItems = Utils.stripNulls([addOnUnsetValues([index], propMetadata.onUnsetValues)])

const indexedPropertyControls = controlDescription.propertyControls[index]

if (indexedPropertyControls.control === 'none') {
return null
}

return (
<InspectorContextMenuWrapper
id={`context-menu-for-${PP.toString(propPathWithIndex)}`}
Expand All @@ -1090,7 +1102,7 @@ const TupleControlItem = React.memo((props: TupleControlItemProps) => {
key={index}
>
<RowForControl
controlDescription={controlDescription.propertyControls[index]}
controlDescription={indexedPropertyControls}
isScene={isScene}
propPath={PP.appendPropertyPathElems(propPath, [index])}
setGlobalCursor={props.setGlobalCursor}
Expand Down Expand Up @@ -1244,6 +1256,9 @@ const RowForObjectControl = React.memo((props: RowForObjectControlProps) => {
open,
mapToArray((innerControl: RegularControlDescription, prop: string, index: number) => {
const innerPropPath = PP.appendPropertyPathElems(propPath, [prop])
if (innerControl.control === 'none') {
return null
}
return (
<RowForControl
key={`object-control-row-${PP.toString(innerPropPath)}`}
Expand Down Expand Up @@ -1343,7 +1358,7 @@ const RowForUnionControl = React.memo((props: RowForUnionControlProps) => {
RowForUnionControl.displayName = 'RowForUnionControl'

interface RowForControlProps extends AbstractRowForControlProps {
controlDescription: RegularControlDescription
controlDescription: Exclude<RegularControlDescription, NoneControlDescription>
disableToggling?: boolean
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const FolderSection = React.memo((props: FolderSectionProps) => {

const createRowForControl = (propName: string, focusOnMount: boolean) => {
const controlDescription = props.propertyControls[propName]
if (controlDescription.control === 'none') {
return null
}
return (
<RowOrFolderWrapper
key={`section-row-${propName}`}
Expand Down Expand Up @@ -126,19 +129,23 @@ export const FolderSection = React.memo((props: FolderSectionProps) => {
propValue,
propName,
)
return (
<RowForControl
key={propName}
propPath={PP.create(propName)}
controlDescription={controlDescription}
isScene={false}
setGlobalCursor={props.setGlobalCursor}
indentationLevel={props.indentationLevel}
shouldIncreaseIdentation={true}
showHiddenControl={props.showHiddenControl}
focusOnMount={false}
/>
)
if (controlDescription.control === 'none') {
return null
} else {
return (
<RowForControl
key={propName}
propPath={PP.create(propName)}
controlDescription={controlDescription}
isScene={false}
setGlobalCursor={props.setGlobalCursor}
indentationLevel={props.indentationLevel}
shouldIncreaseIdentation={true}
showHiddenControl={props.showHiddenControl}
focusOnMount={false}
/>
)
}
}
}),
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ type RowOrFolderWrapperProps = {
}

export const RowOrFolderWrapper = React.memo((props: RowOrFolderWrapperProps) => {
if (props.controlDescription.control === 'none') {
return null
}
return (
<UIGridRow padded={false} tall={false} variant='<-------------1fr------------->'>
<RowForControl
Expand Down
Loading