Skip to content

Commit 740b72d

Browse files
committed
fix: update focus reference methods to accept optional parameters for improved clarity
1 parent c5c35b3 commit 740b72d

File tree

27 files changed

+59
-61
lines changed

27 files changed

+59
-61
lines changed

packages/components/src/components/accordion/shadow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export class KolAccordion implements AccordionAPI, FocusableElement {
4545
private readonly nonce = nonce();
4646
private buttonWcRef?: HTMLKolButtonWcElement;
4747

48-
private readonly setButtonWcRef = (ref: HTMLKolButtonWcElement | null) => {
49-
this.buttonWcRef = ref || undefined;
48+
private readonly setButtonWcRef = (ref?: HTMLKolButtonWcElement) => {
49+
this.buttonWcRef = ref;
5050
};
5151

5252
/**

packages/components/src/components/badge/shadow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export class KolBadge implements BadgeAPI, FocusableElement {
2929
private readonly id = nonce();
3030
private smartButtonRef?: HTMLKolButtonWcElement;
3131

32-
private readonly setSmartButtonRef = (ref: HTMLKolButtonWcElement | null) => {
33-
this.smartButtonRef = ref || undefined;
32+
private readonly setSmartButtonRef = (ref?: HTMLKolButtonWcElement) => {
33+
this.smartButtonRef = ref;
3434
};
3535

3636
private renderSmartButton(props: InternalButtonProps): JSX.Element {

packages/components/src/components/button-link/shadow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ export class KolButtonLink implements ButtonLinkProps, FocusableElement {
4545
@Element() private readonly host?: HTMLKolButtonLinkElement;
4646
private buttonWcRef?: HTMLKolButtonWcElement;
4747

48-
private readonly setButtonWcRef = (ref: HTMLKolButtonWcElement | null) => {
49-
this.buttonWcRef = ref || undefined;
48+
private readonly setButtonWcRef = (ref?: HTMLKolButtonWcElement) => {
49+
this.buttonWcRef = ref;
5050
};
5151

5252
/**

packages/components/src/components/combobox/shadow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ export class KolCombobox implements ComboboxAPI, FocusableElement {
9090
}
9191
}
9292
};
93-
private readonly setInputRef = (ref: HTMLInputElement | null) => {
94-
this.refInput = ref || undefined;
93+
private readonly setInputRef = (ref?: HTMLInputElement) => {
94+
this.refInput = ref;
9595
};
9696

9797
private selectOption(option: string) {

packages/components/src/components/details/shadow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ export class KolDetails implements DetailsAPI, FocusableElement {
3131
private readonly nonce = nonce();
3232
private buttonWcRef?: HTMLKolButtonWcElement;
3333

34-
private readonly setButtonWcRef = (ref: HTMLKolButtonWcElement | null) => {
35-
this.buttonWcRef = ref || undefined;
34+
private readonly setButtonWcRef = (ref?: HTMLKolButtonWcElement) => {
35+
this.buttonWcRef = ref;
3636
};
3737

3838
/**

packages/components/src/components/input-checkbox/shadow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export class KolInputCheckbox implements InputCheckboxAPI, FocusableElement {
5454
@Element() private readonly host?: HTMLKolInputCheckboxElement;
5555
private inputRef?: HTMLInputElement;
5656

57-
private readonly setInputRef = (ref: HTMLInputElement | null) => {
58-
this.inputRef = ref || undefined;
57+
private readonly setInputRef = (ref?: HTMLInputElement) => {
58+
this.inputRef = ref;
5959
};
6060

6161
private getModelValue(): StencilUnknown {

packages/components/src/components/input-color/shadow.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ export class KolInputColor implements InputColorAPI, FocusableElement {
4646
private refInputText?: HTMLInputElement;
4747
private refInputColor?: HTMLInputElement;
4848

49-
private readonly setInputRef = (ref: HTMLInputElement | null) => {
50-
this.refInputText = ref || undefined;
49+
private readonly setInputRef = (ref?: HTMLInputElement) => {
50+
this.refInputText = ref;
5151
};
52-
private readonly setColorRef = (ref: HTMLInputElement | null) => {
53-
this.refInputColor = ref || undefined;
52+
private readonly setColorRef = (ref?: HTMLInputElement) => {
53+
this.refInputColor = ref;
5454
};
5555
private readonly onBlur = (event: FocusEvent) => {
5656
this.controller.onFacade.onBlur(event);

packages/components/src/components/input-date/shadow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export class KolInputDate implements InputDateAPI, FocusableElement {
5656

5757
@State() private _initialValueType: 'Date' | 'String' | null = null;
5858

59-
private readonly setInputRef = (ref: HTMLInputElement | null) => {
60-
this.inputRef = ref || undefined;
59+
private readonly setInputRef = (ref?: HTMLInputElement) => {
60+
this.inputRef = ref;
6161
};
6262

6363
/**

packages/components/src/components/input-email/shadow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ export class KolInputEmail implements InputEmailAPI, FocusableElement {
5454
@Element() private readonly host?: HTMLKolInputEmailElement;
5555
private inputRef?: HTMLInputElement;
5656

57-
private readonly setInputRef = (ref: HTMLInputElement | null) => {
58-
this.inputRef = ref || undefined;
57+
private readonly setInputRef = (ref?: HTMLInputElement) => {
58+
this.inputRef = ref;
5959
};
6060

6161
/**

packages/components/src/components/input-file/shadow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ export class KolInputFile implements InputFileAPI, FocusableElement {
5353
private readonly translateDataBrowseText = translate('kol-data-browse-text');
5454
private readonly translateFilenameText = translate('kol-filename-text');
5555

56-
private readonly setInputRef = (ref: HTMLInputElement | null) => {
57-
this.inputRef = ref || undefined;
56+
private readonly setInputRef = (ref?: HTMLInputElement) => {
57+
this.inputRef = ref;
5858
};
5959

6060
/**

0 commit comments

Comments
 (0)