Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(input, input-number, input-text): restore autofocus, enter-key-mode and input-mode attributes #9245

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions packages/calcite-components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2034,6 +2034,10 @@ export namespace Components {
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
*/
"autocomplete": string;
/**
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
*/
"autofocus": boolean;
/**
* 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.
*/
Expand All @@ -2044,6 +2048,11 @@ export namespace Components {
*/
"disabled": boolean;
"editingEnabled": boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"enterKeyHint": string;
/**
* When `type` is `"file"`, specifies the component's selected files.
* @mdn https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files
Expand All @@ -2065,6 +2074,11 @@ export namespace Components {
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
*/
"iconFlipRtl": boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"inputMode": string;
/**
* Accessible name for the component.
*/
Expand Down Expand Up @@ -2364,6 +2378,10 @@ export namespace Components {
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
*/
"autocomplete": string;
/**
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
*/
"autofocus": boolean;
/**
* When `true`, a clear button is displayed when the component has a value.
*/
Expand All @@ -2374,6 +2392,11 @@ export namespace Components {
*/
"disabled": boolean;
"editingEnabled": boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"enterKeyHint": string;
/**
* 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.
*/
Expand All @@ -2391,6 +2414,11 @@ export namespace Components {
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
*/
"iconFlipRtl": boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"inputMode": string;
/**
* When `true`, restricts the component to integer numbers only and disables exponential notation.
*/
Expand Down Expand Up @@ -2522,6 +2550,10 @@ export namespace Components {
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
*/
"autocomplete": string;
/**
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
*/
"autofocus": boolean;
/**
* When `true`, a clear button is displayed when the component has a value.
*/
Expand All @@ -2532,6 +2564,11 @@ export namespace Components {
*/
"disabled": boolean;
"editingEnabled": boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"enterKeyHint": string;
/**
* 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.
*/
Expand All @@ -2545,6 +2582,11 @@ export namespace Components {
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
*/
"iconFlipRtl": boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"inputMode": string;
/**
* Accessible name for the component's button or hyperlink.
*/
Expand Down Expand Up @@ -9748,6 +9790,10 @@ declare namespace LocalJSX {
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
*/
"autocomplete"?: string;
/**
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
*/
"autofocus"?: boolean;
/**
* 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.
*/
Expand All @@ -9758,6 +9804,11 @@ declare namespace LocalJSX {
*/
"disabled"?: boolean;
"editingEnabled"?: boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"enterKeyHint"?: string;
/**
* When `type` is `"file"`, specifies the component's selected files.
* @mdn https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/files
Expand All @@ -9779,6 +9830,11 @@ declare namespace LocalJSX {
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
*/
"iconFlipRtl"?: boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"inputMode"?: string;
/**
* Accessible name for the component.
*/
Expand Down Expand Up @@ -10091,6 +10147,10 @@ declare namespace LocalJSX {
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
*/
"autocomplete"?: string;
/**
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
*/
"autofocus"?: boolean;
/**
* When `true`, a clear button is displayed when the component has a value.
*/
Expand All @@ -10101,6 +10161,11 @@ declare namespace LocalJSX {
*/
"disabled"?: boolean;
"editingEnabled"?: boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"enterKeyHint"?: string;
/**
* 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.
*/
Expand All @@ -10118,6 +10183,11 @@ declare namespace LocalJSX {
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
*/
"iconFlipRtl"?: boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"inputMode"?: string;
/**
* When `true`, restricts the component to integer numbers only and disables exponential notation.
*/
Expand Down Expand Up @@ -10251,6 +10321,10 @@ declare namespace LocalJSX {
* @mdn [step](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete)
*/
"autocomplete"?: string;
/**
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
*/
"autofocus"?: boolean;
/**
* When `true`, a clear button is displayed when the component has a value.
*/
Expand All @@ -10261,6 +10335,11 @@ declare namespace LocalJSX {
*/
"disabled"?: boolean;
"editingEnabled"?: boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"enterKeyHint"?: string;
/**
* 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.
*/
Expand All @@ -10274,6 +10353,11 @@ declare namespace LocalJSX {
* When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`).
*/
"iconFlipRtl"?: boolean;
/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
* @futureBreaking kebab-cased attribute will not be supported in a future release
*/
"inputMode"?: string;
/**
* Accessible name for the component's button or hyperlink.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ import {
import { getElementRect, getElementXY, selectText } from "../../tests/utils";
import { letterKeys, numberKeys } from "../../utils/key";
import { locales, numberStringFormatter } from "../../utils/locale";
import { testHiddenInputSyncing, testPostValidationFocusing } from "../input/common/tests";
import {
testWorkaroundForGlobalPropRemoval,
testHiddenInputSyncing,
testPostValidationFocusing,
} from "../input/common/tests";

describe("calcite-input-number", () => {
const delayFor2UpdatesInMs = 200;
Expand Down Expand Up @@ -1757,6 +1761,8 @@ describe("calcite-input-number", () => {
testHiddenInputSyncing("calcite-input-number");
});

testWorkaroundForGlobalPropRemoval("calcite-input-number");

describe("translation support", () => {
t9n("calcite-input-number");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ export class InputNumber
/** Specifies the text alignment of the component's value. */
@Prop({ reflect: true }) alignment: Extract<"start" | "end", Alignment> = "start";

/**
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
*
* @internal
*/
// eslint-disable-next-line @stencil-community/reserved-member-names
@Prop() autofocus: boolean;

/**
* When `true`, a clear button is displayed when the component has a value.
*/
Expand All @@ -136,6 +144,15 @@ export class InputNumber
this.setDisabledAction();
}

/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
*
* @futureBreaking kebab-cased attribute will not be supported in a future release
* @internal
*/
// eslint-disable-next-line @stencil-community/reserved-member-names
@Prop() enterKeyHint: string;

/**
* The `id` of the form that will be associated with the component.
*
Expand All @@ -158,6 +175,15 @@ export class InputNumber
/** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */
@Prop({ reflect: true }) iconFlipRtl = false;

/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
*
* @futureBreaking kebab-cased attribute will not be supported in a future release
* @internal
*/
// eslint-disable-next-line @stencil-community/reserved-member-names
@Prop() inputMode: string;

/** When `true`, restricts the component to integer numbers only and disables exponential notation. */
@Prop() integer = false;

Expand Down Expand Up @@ -1059,8 +1085,8 @@ export class InputNumber
autofocus={this.el.autofocus ? true : null}
defaultValue={this.defaultValue}
disabled={this.disabled ? true : null}
enterKeyHint={this.el.enterKeyHint}
inputMode={this.el.inputMode}
enterKeyHint={this.el.enterKeyHint || this.el.getAttribute("enterkeyhint")}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks a little odd to me because you could just do

enterKeyHint={this.enterKeyHint}

But I get why its like the way you have. So its easier to remove the property in the future breaking change release 👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually needed since the component prop won't be populated if I set the global attribute. The custom props override the native behavior, so the prop will not be set when using the native global attributes.

inputMode={this.el.inputMode || this.el.getAttribute("inputmode")}
key="localized-input"
maxLength={this.maxLength}
minLength={this.minLength}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ import {
t9n,
} from "../../tests/commonTests";
import { selectText } from "../../tests/utils";
import { testHiddenInputSyncing, testPostValidationFocusing } from "../input/common/tests";
import {
testHiddenInputSyncing,
testPostValidationFocusing,
testWorkaroundForGlobalPropRemoval,
} from "../input/common/tests";

describe("calcite-input-text", () => {
describe("labelable", () => {
Expand Down Expand Up @@ -469,6 +473,8 @@ describe("calcite-input-text", () => {
testHiddenInputSyncing("calcite-input-text");
});

testWorkaroundForGlobalPropRemoval("calcite-input-text");

describe("translation support", () => {
t9n("calcite-input-text");
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ export class InputText
/** Specifies the text alignment of the component's value. */
@Prop({ reflect: true }) alignment: Extract<"start" | "end", Alignment> = "start";

/**
* Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726
*
* @internal
*/
// eslint-disable-next-line @stencil-community/reserved-member-names
@Prop() autofocus: boolean;

/**
* When `true`, a clear button is displayed when the component has a value.
*/
Expand All @@ -112,6 +120,15 @@ export class InputText
this.setDisabledAction();
}

/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
*
* @futureBreaking kebab-cased attribute will not be supported in a future release
* @internal
*/
// eslint-disable-next-line @stencil-community/reserved-member-names
@Prop() enterKeyHint: string;

/**
* The `id` of the form that will be associated with the component.
*
Expand All @@ -130,6 +147,15 @@ export class InputText
/** When `true`, the icon will be flipped when the element direction is right-to-left (`"rtl"`). */
@Prop({ reflect: true }) iconFlipRtl = false;

/**
* Adds support for kebab-cased attribute, removed in https://github.com/Esri/calcite-design-system/pull/9123
*
* @futureBreaking kebab-cased attribute will not be supported in a future release
* @internal
*/
// eslint-disable-next-line @stencil-community/reserved-member-names
@Prop() inputMode: string;

/** Accessible name for the component's button or hyperlink. */
@Prop() label: string;

Expand Down Expand Up @@ -632,7 +658,6 @@ export class InputText
/>
);
const prefixText = <div class={CSS.prefix}>{this.prefixText}</div>;

const suffixText = <div class={CSS.suffix}>{this.suffixText}</div>;

const childEl = (
Expand All @@ -646,8 +671,8 @@ export class InputText
}}
defaultValue={this.defaultValue}
disabled={this.disabled ? true : null}
enterKeyHint={this.el.enterKeyHint}
inputMode={this.el.inputMode}
enterKeyHint={this.el.enterKeyHint || this.el.getAttribute("enterkeyhint")}
inputMode={this.el.inputMode || this.el.getAttribute("inputmode")}
maxLength={this.maxLength}
minLength={this.minLength}
name={this.name}
Expand Down
Loading
Loading