From 1c94e2c7ca34820b9c4c2a2bd59cc632744c5f40 Mon Sep 17 00:00:00 2001 From: Skaiir Date: Thu, 3 Oct 2024 08:12:22 +0200 Subject: [PATCH] fix: do not create a simple label in datetime components Closes #1268 --- .../properties-panel/PropertiesPanelHeaderProvider.js | 3 +++ .../test/spec/core/FieldFactory.spec.js | 1 - packages/form-js-viewer/src/core/FieldFactory.js | 11 ++++------- .../render/components/form-fields/Datetime.spec.js | 1 - 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/form-js-editor/src/features/properties-panel/PropertiesPanelHeaderProvider.js b/packages/form-js-editor/src/features/properties-panel/PropertiesPanelHeaderProvider.js index ba38b0cf6..47a4eeefb 100644 --- a/packages/form-js-editor/src/features/properties-panel/PropertiesPanelHeaderProvider.js +++ b/packages/form-js-editor/src/features/properties-panel/PropertiesPanelHeaderProvider.js @@ -13,6 +13,9 @@ export function getPropertiesPanelHeaderProvider(options = {}) { if (headerlessTypes.includes(type)) { return ''; } + if (type === 'datetime') { + return field.dateLabel || field.timeLabel; + } if (type === 'text') { return textToLabel(field.text); } diff --git a/packages/form-js-editor/test/spec/core/FieldFactory.spec.js b/packages/form-js-editor/test/spec/core/FieldFactory.spec.js index df130c740..e658e90e4 100644 --- a/packages/form-js-editor/test/spec/core/FieldFactory.spec.js +++ b/packages/form-js-editor/test/spec/core/FieldFactory.spec.js @@ -120,7 +120,6 @@ describe('core/FieldFactory', function () { 'Date time', testCreate({ type: 'datetime', - label: 'Date time', keyed: true, defaults: { subtype: 'date', diff --git a/packages/form-js-viewer/src/core/FieldFactory.js b/packages/form-js-viewer/src/core/FieldFactory.js index 499b3a914..42f94899d 100644 --- a/packages/form-js-viewer/src/core/FieldFactory.js +++ b/packages/form-js-viewer/src/core/FieldFactory.js @@ -60,15 +60,12 @@ export class FieldFactory { throw new Error(`binding path '${[...parentPath, ...path.split('.')].join('.')}' is already claimed`); } - const labelAttrs = - applyDefaults && config.label - ? { - label: config.label, - } - : {}; + // currently using a hard coded solution while we evaluate refactoring + // cf. https://github.com/bpmn-io/form-js/issues/1291 + const shouldApplyLabel = applyDefaults && !(config.type === 'datetime') && config.label; const field = config.create({ - ...labelAttrs, + ...(shouldApplyLabel ? { label: config.label } : {}), ...attrs, }); diff --git a/packages/form-js-viewer/test/spec/render/components/form-fields/Datetime.spec.js b/packages/form-js-viewer/test/spec/render/components/form-fields/Datetime.spec.js index 0f05ce213..bd7d40d68 100644 --- a/packages/form-js-viewer/test/spec/render/components/form-fields/Datetime.spec.js +++ b/packages/form-js-viewer/test/spec/render/components/form-fields/Datetime.spec.js @@ -891,7 +891,6 @@ describe('Datetime', function () { // assume const { config } = Datetime; expect(config.type).to.eql('datetime'); - expect(config.label).to.eql('Date time'); expect(config.group).to.eql('basic-input'); expect(config.keyed).to.be.true;