Skip to content

Commit

Permalink
fix(ui-library): changed default params of value (#1173)
Browse files Browse the repository at this point in the history
* fix(ui-library): changed default params of value

fix(ui-library): update value on readonly

* fix(ui-library): type errors fixed for lint analyze pipeline (#1171)

* fix(ui-library): type errors fixed for lint analyze pipeline

* fix(ui-library): fix eslint issue

* fix(ui-library): changed to develop code

* fix(ui-library): update value on readonly

---------

Signed-off-by: ashk1996 <125904756+ashk1996@users.noreply.github.com>
  • Loading branch information
ashk1996 authored Dec 3, 2024
1 parent 21856a3 commit 0295e9e
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/ui-library/src/components/input-field-number/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export class BlrInputFieldNumber extends LitElementCustom {
@property({ type: Boolean }) accessor hasHint = true;
@property() accessor hintMessage: string | undefined;
@property() accessor hintMessageIcon: SizelessIconType | undefined;
@property({ type: Number }) accessor value: number | undefined;
@property() accessor value: number | string | undefined;
@property({ type: Number }) accessor step: number | undefined;
@property() accessor unit: UnitType | undefined;
@property({ type: Number }) accessor leadingZeros: number | undefined;
Expand All @@ -77,7 +77,7 @@ export class BlrInputFieldNumber extends LitElementCustom {

@property() accessor theme: ThemeType = 'Light_value';

@state() protected accessor currentValue = 0;
@state() protected accessor currentValue: number | undefined;
@state() protected accessor isFocused = false;

protected stepperUp(event: MouseEvent) {
Expand Down Expand Up @@ -106,7 +106,10 @@ export class BlrInputFieldNumber extends LitElementCustom {

connectedCallback() {
super.connectedCallback();
this.currentValue = Number(this.currentValue) || Number(this.value) || 0;

if (this.value !== '') {
this.currentValue = Number(this.currentValue) || Number(this.value);
}
}

protected handleFocus = (event: FocusEvent) => {
Expand Down Expand Up @@ -321,9 +324,9 @@ export class BlrInputFieldNumber extends LitElementCustom {
id="${this.inputFieldNumberId}"
class="${inputClasses}"
type="number"
.value=${this.currentValue != 0
.value=${this.currentValue !== undefined
? this.customFormat(this.currentValue || 0, this.decimals || 0, this.leadingZeros || 0)
: '0'}
: ''}
step="${this.step !== undefined ? this.step : 1}"
?disabled="${this.disabled}"
?readonly="${this.readonly}"
Expand Down

0 comments on commit 0295e9e

Please sign in to comment.