From 6f91df7e059ae98e72d231570e8a9e9d31c2b7af Mon Sep 17 00:00:00 2001 From: mJarsater <62651103+mJarsater@users.noreply.github.com> Date: Fri, 27 Oct 2023 17:20:47 +0200 Subject: [PATCH] fix: stepper hideLabels in runtime (#398) * fix(stepper): make hideLabels be able to update in runtime There was a mismatch in naming between the prop of tds-stepper and tds-step. --- .../core/src/components/stepper/step/step.tsx | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/core/src/components/stepper/step/step.tsx b/packages/core/src/components/stepper/step/step.tsx index d012a40f8..fd30af2a1 100644 --- a/packages/core/src/components/stepper/step/step.tsx +++ b/packages/core/src/components/stepper/step/step.tsx @@ -1,6 +1,13 @@ import { Component, Host, h, Prop, Element, State, Listen } from '@stencil/core'; import { InternalTdsStepperPropChange } from '../stepper'; +const propToStateMap = { + orientation: 'orientation', + labelPosition: 'labelPosition', + size: 'size', + hideLabels: 'hideLabels', +}; + /** * @slot label - Slot for the label text. */ @@ -16,7 +23,7 @@ export class TdsStep { /** State of the Step */ @Prop() state: 'current' | 'error' | 'success' | 'upcoming' = 'upcoming'; - @State() hideLabel: boolean; + @State() hideLabels: boolean; @State() size: 'sm' | 'lg'; @@ -36,7 +43,7 @@ export class TdsStep { this.orientation = this.stepperEl.orientation; this.labelPosition = this.stepperEl.labelPosition; this.size = this.stepperEl.size; - this.hideLabel = this.stepperEl.hideLabels; + this.hideLabels = this.stepperEl.hideLabels; this.stepperId = this.stepperEl.stepperId; } @@ -45,12 +52,10 @@ export class TdsStep { if (this.stepperId === event.detail.stepperId) { event.detail.changed.forEach((changedProp) => { if (typeof this[changedProp] === 'undefined') { - throw new Error(`Table prop is not supported: ${changedProp}`); - } - if (this[changedProp] === this.orientation && event.detail[changedProp] === 'vertical') { - this.labelPosition = 'aside'; + throw new Error(`Stepper prop is not supported: ${changedProp}`); + } else if (changedProp in propToStateMap) { + this[propToStateMap[changedProp]] = event.detail[changedProp]; } - this[changedProp] = event.detail[changedProp]; }); } } @@ -61,7 +66,7 @@ export class TdsStep {
@@ -74,7 +79,7 @@ export class TdsStep { this.index )}
- {!this.hideLabel && ( + {!this.hideLabels && (