Skip to content

Commit 0498c6e

Browse files
jcfrancobenelan
andauthored
fix(input, input-number, input-text): restore autofocus, enter-key-mode and input-mode attributes (#9245) (#9306)
**Related Issue:** #9235 ## Summary This fixes the following issues introduced by #9123 when component props that shadowed global attributes were removed: * the kebab-cased attribute names of those props would no longer work (namely, `enter-key-mode`, `input-mode`) * `autofocus` was missing from component types as Stencil does not include it in the base `HTMLAttribute` type (see stenciljs/core#5726). Co-authored-by: Ben Elan <[email protected]>
1 parent 0e828b6 commit 0498c6e

File tree

8 files changed

+245
-17
lines changed

8 files changed

+245
-17
lines changed

packages/calcite-components/src/components.d.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,6 +2034,10 @@ export namespace Components {
20342034
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
20352035
*/
20362036
"autocomplete": string;
2037+
/**
2038+
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
2039+
*/
2040+
"autofocus": boolean;
20372041
/**
20382042
* When `true`, a clear button is displayed when the component has a value. The clear button shows by default for `"search"`, `"time"`, and `"date"` types, and will not display for the `"textarea"` type.
20392043
*/
@@ -2044,6 +2048,11 @@ export namespace Components {
20442048
*/
20452049
"disabled": boolean;
20462050
"editingEnabled": boolean;
2051+
/**
2052+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
2053+
* @futureBreaking kebab-cased attribute will not be supported in a future release
2054+
*/
2055+
"enterKeyHint": string;
20472056
/**
20482057
* When `type` is `"file"`, specifies the component's selected files.
20492058
* @mdn https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files
@@ -2065,6 +2074,11 @@ export namespace Components {
20652074
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
20662075
*/
20672076
"iconFlipRtl": boolean;
2077+
/**
2078+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
2079+
* @futureBreaking kebab-cased attribute will not be supported in a future release
2080+
*/
2081+
"inputMode": string;
20682082
/**
20692083
* Accessible name for the component.
20702084
*/
@@ -2364,6 +2378,10 @@ export namespace Components {
23642378
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
23652379
*/
23662380
"autocomplete": string;
2381+
/**
2382+
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
2383+
*/
2384+
"autofocus": boolean;
23672385
/**
23682386
* When `true`, a clear button is displayed when the component has a value.
23692387
*/
@@ -2374,6 +2392,11 @@ export namespace Components {
23742392
*/
23752393
"disabled": boolean;
23762394
"editingEnabled": boolean;
2395+
/**
2396+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
2397+
* @futureBreaking kebab-cased attribute will not be supported in a future release
2398+
*/
2399+
"enterKeyHint": string;
23772400
/**
23782401
* The `id` of the form that will be associated with the component. When not set, the component will be associated with its ancestor form element, if any.
23792402
*/
@@ -2391,6 +2414,11 @@ export namespace Components {
23912414
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
23922415
*/
23932416
"iconFlipRtl": boolean;
2417+
/**
2418+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
2419+
* @futureBreaking kebab-cased attribute will not be supported in a future release
2420+
*/
2421+
"inputMode": string;
23942422
/**
23952423
* When `true`, restricts the component to integer numbers only and disables exponential notation.
23962424
*/
@@ -2522,6 +2550,10 @@ export namespace Components {
25222550
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
25232551
*/
25242552
"autocomplete": string;
2553+
/**
2554+
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
2555+
*/
2556+
"autofocus": boolean;
25252557
/**
25262558
* When `true`, a clear button is displayed when the component has a value.
25272559
*/
@@ -2532,6 +2564,11 @@ export namespace Components {
25322564
*/
25332565
"disabled": boolean;
25342566
"editingEnabled": boolean;
2567+
/**
2568+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
2569+
* @futureBreaking kebab-cased attribute will not be supported in a future release
2570+
*/
2571+
"enterKeyHint": string;
25352572
/**
25362573
* The `id` of the form that will be associated with the component. When not set, the component will be associated with its ancestor form element, if any.
25372574
*/
@@ -2545,6 +2582,11 @@ export namespace Components {
25452582
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
25462583
*/
25472584
"iconFlipRtl": boolean;
2585+
/**
2586+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
2587+
* @futureBreaking kebab-cased attribute will not be supported in a future release
2588+
*/
2589+
"inputMode": string;
25482590
/**
25492591
* Accessible name for the component's button or hyperlink.
25502592
*/
@@ -9748,6 +9790,10 @@ declare namespace LocalJSX {
97489790
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
97499791
*/
97509792
"autocomplete"?: string;
9793+
/**
9794+
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
9795+
*/
9796+
"autofocus"?: boolean;
97519797
/**
97529798
* When `true`, a clear button is displayed when the component has a value. The clear button shows by default for `"search"`, `"time"`, and `"date"` types, and will not display for the `"textarea"` type.
97539799
*/
@@ -9758,6 +9804,11 @@ declare namespace LocalJSX {
97589804
*/
97599805
"disabled"?: boolean;
97609806
"editingEnabled"?: boolean;
9807+
/**
9808+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
9809+
* @futureBreaking kebab-cased attribute will not be supported in a future release
9810+
*/
9811+
"enterKeyHint"?: string;
97619812
/**
97629813
* When `type` is `"file"`, specifies the component's selected files.
97639814
* @mdn https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files
@@ -9779,6 +9830,11 @@ declare namespace LocalJSX {
97799830
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
97809831
*/
97819832
"iconFlipRtl"?: boolean;
9833+
/**
9834+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
9835+
* @futureBreaking kebab-cased attribute will not be supported in a future release
9836+
*/
9837+
"inputMode"?: string;
97829838
/**
97839839
* Accessible name for the component.
97849840
*/
@@ -10091,6 +10147,10 @@ declare namespace LocalJSX {
1009110147
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
1009210148
*/
1009310149
"autocomplete"?: string;
10150+
/**
10151+
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
10152+
*/
10153+
"autofocus"?: boolean;
1009410154
/**
1009510155
* When `true`, a clear button is displayed when the component has a value.
1009610156
*/
@@ -10101,6 +10161,11 @@ declare namespace LocalJSX {
1010110161
*/
1010210162
"disabled"?: boolean;
1010310163
"editingEnabled"?: boolean;
10164+
/**
10165+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
10166+
* @futureBreaking kebab-cased attribute will not be supported in a future release
10167+
*/
10168+
"enterKeyHint"?: string;
1010410169
/**
1010510170
* The `id` of the form that will be associated with the component. When not set, the component will be associated with its ancestor form element, if any.
1010610171
*/
@@ -10118,6 +10183,11 @@ declare namespace LocalJSX {
1011810183
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
1011910184
*/
1012010185
"iconFlipRtl"?: boolean;
10186+
/**
10187+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
10188+
* @futureBreaking kebab-cased attribute will not be supported in a future release
10189+
*/
10190+
"inputMode"?: string;
1012110191
/**
1012210192
* When `true`, restricts the component to integer numbers only and disables exponential notation.
1012310193
*/
@@ -10251,6 +10321,10 @@ declare namespace LocalJSX {
1025110321
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
1025210322
*/
1025310323
"autocomplete"?: string;
10324+
/**
10325+
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
10326+
*/
10327+
"autofocus"?: boolean;
1025410328
/**
1025510329
* When `true`, a clear button is displayed when the component has a value.
1025610330
*/
@@ -10261,6 +10335,11 @@ declare namespace LocalJSX {
1026110335
*/
1026210336
"disabled"?: boolean;
1026310337
"editingEnabled"?: boolean;
10338+
/**
10339+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
10340+
* @futureBreaking kebab-cased attribute will not be supported in a future release
10341+
*/
10342+
"enterKeyHint"?: string;
1026410343
/**
1026510344
* The `id` of the form that will be associated with the component. When not set, the component will be associated with its ancestor form element, if any.
1026610345
*/
@@ -10274,6 +10353,11 @@ declare namespace LocalJSX {
1027410353
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
1027510354
*/
1027610355
"iconFlipRtl"?: boolean;
10356+
/**
10357+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
10358+
* @futureBreaking kebab-cased attribute will not be supported in a future release
10359+
*/
10360+
"inputMode"?: string;
1027710361
/**
1027810362
* Accessible name for the component's button or hyperlink.
1027910363
*/

packages/calcite-components/src/components/input-number/input-number.e2e.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ import {
1515
import { getElementRect, getElementXY, selectText } from "../../tests/utils";
1616
import { letterKeys, numberKeys } from "../../utils/key";
1717
import { locales, numberStringFormatter } from "../../utils/locale";
18-
import { testHiddenInputSyncing, testPostValidationFocusing } from "../input/common/tests";
18+
import {
19+
testWorkaroundForGlobalPropRemoval,
20+
testHiddenInputSyncing,
21+
testPostValidationFocusing,
22+
} from "../input/common/tests";
1923

2024
describe("calcite-input-number", () => {
2125
const delayFor2UpdatesInMs = 200;
@@ -1757,6 +1761,8 @@ describe("calcite-input-number", () => {
17571761
testHiddenInputSyncing("calcite-input-number");
17581762
});
17591763

1764+
testWorkaroundForGlobalPropRemoval("calcite-input-number");
1765+
17601766
describe("translation support", () => {
17611767
t9n("calcite-input-number");
17621768
});

packages/calcite-components/src/components/input-number/input-number.tsx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ export class InputNumber
119119
/** Specifies the text alignment of the component's value. */
120120
@Prop({ reflect: true }) alignment: Extract<"start" | "end", Alignment> = "start";
121121

122+
/**
123+
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
124+
*
125+
* @internal
126+
*/
127+
// eslint-disable-next-line @stencil-community/reserved-member-names
128+
@Prop() autofocus: boolean;
129+
122130
/**
123131
* When `true`, a clear button is displayed when the component has a value.
124132
*/
@@ -136,6 +144,15 @@ export class InputNumber
136144
this.setDisabledAction();
137145
}
138146

147+
/**
148+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
149+
*
150+
* @futureBreaking kebab-cased attribute will not be supported in a future release
151+
* @internal
152+
*/
153+
// eslint-disable-next-line @stencil-community/reserved-member-names
154+
@Prop() enterKeyHint: string;
155+
139156
/**
140157
* The `id` of the form that will be associated with the component.
141158
*
@@ -158,6 +175,15 @@ export class InputNumber
158175
/** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */
159176
@Prop({ reflect: true }) iconFlipRtl = false;
160177

178+
/**
179+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
180+
*
181+
* @futureBreaking kebab-cased attribute will not be supported in a future release
182+
* @internal
183+
*/
184+
// eslint-disable-next-line @stencil-community/reserved-member-names
185+
@Prop() inputMode: string;
186+
161187
/** When `true`, restricts the component to integer numbers only and disables exponential notation. */
162188
@Prop() integer = false;
163189

@@ -1059,8 +1085,8 @@ export class InputNumber
10591085
autofocus={this.el.autofocus ? true : null}
10601086
defaultValue={this.defaultValue}
10611087
disabled={this.disabled ? true : null}
1062-
enterKeyHint={this.el.enterKeyHint}
1063-
inputMode={this.el.inputMode}
1088+
enterKeyHint={this.el.enterKeyHint || this.el.getAttribute("enterkeyhint")}
1089+
inputMode={this.el.inputMode || this.el.getAttribute("inputmode")}
10641090
key="localized-input"
10651091
maxLength={this.maxLength}
10661092
minLength={this.minLength}

packages/calcite-components/src/components/input-text/input-text.e2e.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ import {
1212
t9n,
1313
} from "../../tests/commonTests";
1414
import { selectText } from "../../tests/utils";
15-
import { testHiddenInputSyncing, testPostValidationFocusing } from "../input/common/tests";
15+
import {
16+
testHiddenInputSyncing,
17+
testPostValidationFocusing,
18+
testWorkaroundForGlobalPropRemoval,
19+
} from "../input/common/tests";
1620

1721
describe("calcite-input-text", () => {
1822
describe("labelable", () => {
@@ -469,6 +473,8 @@ describe("calcite-input-text", () => {
469473
testHiddenInputSyncing("calcite-input-text");
470474
});
471475

476+
testWorkaroundForGlobalPropRemoval("calcite-input-text");
477+
472478
describe("translation support", () => {
473479
t9n("calcite-input-text");
474480
});

packages/calcite-components/src/components/input-text/input-text.tsx

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ export class InputText
9595
/** Specifies the text alignment of the component's value. */
9696
@Prop({ reflect: true }) alignment: Extract<"start" | "end", Alignment> = "start";
9797

98+
/**
99+
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
100+
*
101+
* @internal
102+
*/
103+
// eslint-disable-next-line @stencil-community/reserved-member-names
104+
@Prop() autofocus: boolean;
105+
98106
/**
99107
* When `true`, a clear button is displayed when the component has a value.
100108
*/
@@ -112,6 +120,15 @@ export class InputText
112120
this.setDisabledAction();
113121
}
114122

123+
/**
124+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
125+
*
126+
* @futureBreaking kebab-cased attribute will not be supported in a future release
127+
* @internal
128+
*/
129+
// eslint-disable-next-line @stencil-community/reserved-member-names
130+
@Prop() enterKeyHint: string;
131+
115132
/**
116133
* The `id` of the form that will be associated with the component.
117134
*
@@ -130,6 +147,15 @@ export class InputText
130147
/** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */
131148
@Prop({ reflect: true }) iconFlipRtl = false;
132149

150+
/**
151+
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
152+
*
153+
* @futureBreaking kebab-cased attribute will not be supported in a future release
154+
* @internal
155+
*/
156+
// eslint-disable-next-line @stencil-community/reserved-member-names
157+
@Prop() inputMode: string;
158+
133159
/** Accessible name for the component's button or hyperlink. */
134160
@Prop() label: string;
135161

@@ -632,7 +658,6 @@ export class InputText
632658
/>
633659
);
634660
const prefixText = <div class={CSS.prefix}>{this.prefixText}</div>;
635-
636661
const suffixText = <div class={CSS.suffix}>{this.suffixText}</div>;
637662

638663
const childEl = (
@@ -646,8 +671,8 @@ export class InputText
646671
}}
647672
defaultValue={this.defaultValue}
648673
disabled={this.disabled ? true : null}
649-
enterKeyHint={this.el.enterKeyHint}
650-
inputMode={this.el.inputMode}
674+
enterKeyHint={this.el.enterKeyHint || this.el.getAttribute("enterkeyhint")}
675+
inputMode={this.el.inputMode || this.el.getAttribute("inputmode")}
651676
maxLength={this.maxLength}
652677
minLength={this.minLength}
653678
name={this.name}

0 commit comments

Comments
 (0)