From cd602589eb013341e927ae04b26fa960c98a25ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pau=20Tom=C3=A0s?= Date: Mon, 18 Nov 2024 22:48:59 +0000 Subject: [PATCH 1/2] Fix checkbox not working on engine fields --- src/components/settings/EngineFieldsEditor.tsx | 6 ++---- src/shared/lib/entities/entitiesTypes.ts | 2 +- src/shared/lib/resources/types.ts | 4 +--- src/store/features/entities/entitiesState.ts | 2 +- 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/components/settings/EngineFieldsEditor.tsx b/src/components/settings/EngineFieldsEditor.tsx index 4660fdfcc..4a49ff124 100644 --- a/src/components/settings/EngineFieldsEditor.tsx +++ b/src/components/settings/EngineFieldsEditor.tsx @@ -124,14 +124,12 @@ export const EngineFieldInput: FC = ({ ); } if (field.type === "checkbox") { - const theValue = - typeof value === "boolean" ? Boolean(value) : Boolean(field.defaultValue); return ( onChange(e.currentTarget.checked)} + checked={value === 1 ? true : false} + onChange={(e) => onChange(e.currentTarget.checked === true ? 1 : 0)} /> ); } diff --git a/src/shared/lib/entities/entitiesTypes.ts b/src/shared/lib/entities/entitiesTypes.ts index 9f8f30a8c..a628e4710 100644 --- a/src/shared/lib/entities/entitiesTypes.ts +++ b/src/shared/lib/entities/entitiesTypes.ts @@ -333,7 +333,7 @@ export type CustomEventNormalized = Omit & { export type EngineFieldValue = { id: string; - value?: number | string | boolean | undefined; + value?: number | string | undefined; }; export type MetaspriteTile = { diff --git a/src/shared/lib/resources/types.ts b/src/shared/lib/resources/types.ts index 69d6fe432..3b155c56b 100644 --- a/src/shared/lib/resources/types.ts +++ b/src/shared/lib/resources/types.ts @@ -715,9 +715,7 @@ export type VariablesResource = Static; export const EngineFieldValueData = Type.Object({ id: Type.String(), - value: Type.Optional( - Type.Union([Type.String(), Type.Boolean(), Type.Number()]) - ), + value: Type.Optional(Type.Union([Type.String(), Type.Number()])), }); export type EngineFieldValueData = Static; diff --git a/src/store/features/entities/entitiesState.ts b/src/store/features/entities/entitiesState.ts index 4f4c2fe3f..9b479de95 100644 --- a/src/store/features/entities/entitiesState.ts +++ b/src/store/features/entities/entitiesState.ts @@ -4171,7 +4171,7 @@ const editEngineFieldValue: CaseReducer< EntitiesState, PayloadAction<{ engineFieldId: string; - value: string | number | boolean | undefined; + value: string | number | undefined; }> > = (state, action) => { engineFieldValuesAdapter.upsertOne(state.engineFieldValues, { From d964a56e72d79a1f4fb94ad6ee27f33587b00db4 Mon Sep 17 00:00:00 2001 From: Chris Maltby Date: Wed, 27 Nov 2024 09:54:58 +0000 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 851a3482e..ae199fd51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix issue where changing the dimensions of a sprite png image could cause the sprite editor's tile palette to display incorrectly - Fix line numbers in code editor for GBVM scripts with more than 999 lines - Fix issue preventing projects being created with the name "project" +- Fix issue preventing checkbox type working in engine fields [@pau-tomas](https://github.com/pau-tomas) ## [4.1.3] - 2024-09-16