Skip to content

Commit

Permalink
hotfix: Make component hidden only when visibility is set to false (#…
Browse files Browse the repository at this point in the history
…9029)

* fix: make visibility none only when its set to false

* add visibility only for components which have visibility in styles

* making logic for visibility central

* version bump
  • Loading branch information
stepinfwd committed Mar 11, 2024
1 parent 03182fe commit 1c1d2c6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.32.2
2.32.3
2 changes: 1 addition & 1 deletion frontend/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.32.2
2.32.3
18 changes: 11 additions & 7 deletions frontend/src/Editor/Box.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ export const Box = memo(
const backgroundColor = yellow ? 'yellow' : '';
const currentState = useCurrentState();
const { events } = useAppInfo();
const shouldAddBoxShadowAndVisibility = ['TextInput', 'PasswordInput', 'NumberInput', 'Text'];

const componentMeta = useMemo(() => {
return componentTypes.find((comp) => component.component === comp.component);
Expand All @@ -171,22 +172,26 @@ export const Box = memo(
mode === 'edit' && component.validate
? validateProperties(resolvedProperties, componentMeta.properties)
: [resolvedProperties, []];
if (shouldAddBoxShadowAndVisibility.includes(component.component)) {
validatedProperties.visibility = validatedProperties.visibility !== false ? true : false;
}

const resolvedStyles = resolveStyles(component, currentState, null, customResolvables);

const [validatedStyles, styleErrors] =
mode === 'edit' && component.validate
? validateProperties(resolvedStyles, componentMeta.styles)
: [resolvedStyles, []];

if (!shouldAddBoxShadowAndVisibility.includes(component.component)) {
validatedStyles.visibility = validatedStyles.visibility !== false ? true : false;
}
const resolvedGeneralProperties = resolveGeneralProperties(component, currentState, null, customResolvables);
const [validatedGeneralProperties, generalPropertiesErrors] =
mode === 'edit' && component.validate
? validateProperties(resolvedGeneralProperties, componentMeta.general)
: [resolvedGeneralProperties, []];

const resolvedGeneralStyles = resolveGeneralStyles(component, currentState, null, customResolvables);
resolvedStyles.visibility = resolvedStyles.visibility !== false ? true : false;

const [validatedGeneralStyles, generalStylesErrors] =
mode === 'edit' && component.validate
? validateProperties(resolvedGeneralStyles, componentMeta.generalStyles)
Expand Down Expand Up @@ -276,13 +281,12 @@ export const Box = memo(
...{ validationObject: component.definition.validation, currentState },
customResolveObjects: customResolvables,
});
const shouldAddBoxShadow = ['TextInput', 'PasswordInput', 'NumberInput', 'Text'];
return (
<OverlayTrigger
placement={inCanvas ? 'auto' : 'top'}
delay={{ show: 500, hide: 0 }}
trigger={
inCanvas && shouldAddBoxShadow.includes(component.component)
inCanvas && shouldAddBoxShadowAndVisibility.includes(component.component)
? !validatedProperties.tooltip?.toString().trim()
? null
: ['hover', 'focus']
Expand All @@ -295,7 +299,7 @@ export const Box = memo(
props,
text: inCanvas
? `${
shouldAddBoxShadow.includes(component.component)
shouldAddBoxShadowAndVisibility.includes(component.component)
? validatedProperties.tooltip
: validatedGeneralProperties.tooltip
}`
Expand Down Expand Up @@ -332,7 +336,7 @@ export const Box = memo(
exposedVariables={exposedVariables}
styles={{
...validatedStyles,
...(!shouldAddBoxShadow.includes(component.component)
...(!shouldAddBoxShadowAndVisibility.includes(component.component)
? { boxShadow: validatedGeneralStyles?.boxShadow }
: {}),
}}
Expand Down
2 changes: 1 addition & 1 deletion server/.version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.32.2
2.32.3

0 comments on commit 1c1d2c6

Please sign in to comment.