Skip to content

Commit 1187dc2

Browse files
5im0nmanucorporat
authored andcommitted
feat(searchbar): add inputmode property (ionic-team#18980)
1 parent 3c925bb commit 1187dc2

File tree

10 files changed

+71
-26
lines changed

10 files changed

+71
-26
lines changed

angular/src/directives/proxies.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ export class IonRow {
676676
}
677677

678678
export declare interface IonSearchbar extends Components.IonSearchbar {}
679-
@Component({ selector: 'ion-searchbar', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['animated', 'autocomplete', 'autocorrect', 'cancelButtonIcon', 'cancelButtonText', 'clearIcon', 'color', 'debounce', 'disabled', 'mode', 'placeholder', 'searchIcon', 'showCancelButton', 'spellcheck', 'type', 'value'] })
679+
@Component({ selector: 'ion-searchbar', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['animated', 'autocomplete', 'autocorrect', 'cancelButtonIcon', 'cancelButtonText', 'clearIcon', 'color', 'debounce', 'disabled', 'inputmode', 'mode', 'placeholder', 'searchIcon', 'showCancelButton', 'spellcheck', 'type', 'value'] })
680680
export class IonSearchbar {
681681
ionInput!: EventEmitter<CustomEvent>;
682682
ionChange!: EventEmitter<CustomEvent>;
@@ -692,7 +692,7 @@ export class IonSearchbar {
692692
}
693693
}
694694
proxyMethods(IonSearchbar, ['setFocus', 'getInputElement']);
695-
proxyInputs(IonSearchbar, ['animated', 'autocomplete', 'autocorrect', 'cancelButtonIcon', 'cancelButtonText', 'clearIcon', 'color', 'debounce', 'disabled', 'mode', 'placeholder', 'searchIcon', 'showCancelButton', 'spellcheck', 'type', 'value']);
695+
proxyInputs(IonSearchbar, ['animated', 'autocomplete', 'autocorrect', 'cancelButtonIcon', 'cancelButtonText', 'clearIcon', 'color', 'debounce', 'disabled', 'inputmode', 'mode', 'placeholder', 'searchIcon', 'showCancelButton', 'spellcheck', 'type', 'value']);
696696

697697
export declare interface IonSegment extends Components.IonSegment {}
698698
@Component({ selector: 'ion-segment', changeDetection: ChangeDetectionStrategy.OnPush, template: '<ng-content></ng-content>', inputs: ['color', 'disabled', 'mode', 'scrollable', 'value'] })

core/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,6 +951,7 @@ ion-searchbar,prop,clearIcon,string | undefined,undefined,false,false
951951
ion-searchbar,prop,color,string | undefined,undefined,false,false
952952
ion-searchbar,prop,debounce,number,250,false,false
953953
ion-searchbar,prop,disabled,boolean,false,false,false
954+
ion-searchbar,prop,inputmode,"decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url",'search',false,false
954955
ion-searchbar,prop,mode,"ios" | "md",undefined,false,false
955956
ion-searchbar,prop,placeholder,string,'Search',false,false
956957
ion-searchbar,prop,searchIcon,string,'search',false,false

core/src/components.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,6 +2182,10 @@ export namespace Components {
21822182
*/
21832183
'getInputElement': () => Promise<HTMLInputElement>;
21842184
/**
2185+
* A hint to the browser for which keyboard to display. Possible values are: `"none"` | `"text"` | `"tel"` | `"url"` | `"email"` | `"numeric"` | `"decimal"` | `"search"`.
2186+
*/
2187+
'inputmode': 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
2188+
/**
21852189
* The mode determines which platform styles to use.
21862190
*/
21872191
'mode'?: "ios" | "md";
@@ -5440,6 +5444,10 @@ declare namespace LocalJSX {
54405444
*/
54415445
'disabled'?: boolean;
54425446
/**
5447+
* A hint to the browser for which keyboard to display. Possible values are: `"none"` | `"text"` | `"tel"` | `"url"` | `"email"` | `"numeric"` | `"decimal"` | `"search"`.
5448+
*/
5449+
'inputmode'?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
5450+
/**
54435451
* The mode determines which platform styles to use.
54445452
*/
54455453
'mode'?: "ios" | "md";

core/src/components/searchbar/readme.md

Lines changed: 34 additions & 21 deletions
Large diffs are not rendered by default.

core/src/components/searchbar/searchbar.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ export class Searchbar implements ComponentInterface {
8181
*/
8282
@Prop() disabled = false;
8383

84+
/**
85+
* A hint to the browser for which keyboard to display.
86+
* Possible values are: `"none"` | `"text"` | `"tel"` | `"url"` | `"email"` | `"numeric"` | `"decimal"` | `"search"`.
87+
*/
88+
@Prop() inputmode: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search' = 'search';
89+
8490
/**
8591
* Set the input's placeholder.
8692
* `placeholder` can accept either plaintext or HTML as a string.
@@ -442,6 +448,7 @@ export class Searchbar implements ComponentInterface {
442448
disabled={this.disabled}
443449
ref={el => this.nativeInput = el}
444450
class="searchbar-input"
451+
inputMode={this.inputmode}
445452
onInput={this.onInput}
446453
onBlur={this.onBlur}
447454
onFocus={this.onFocus}

core/src/components/searchbar/test/basic/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ <h5 class="ion-padding-start ion-padding-top"> Search - Cancel Button set to tru
4949
<ion-searchbar id="noCancel" value="after view" autocorrect="off" autocomplete="off" spellcheck="true" type="text" show-cancel-button="focus">
5050
</ion-searchbar>
5151

52+
<h5 class="ion-padding-start ion-padding-top"> Search - Input mode set to numeric</h5>
53+
<ion-searchbar id="noCancel" value="after view" inputmode="numeric" autocorrect="off" autocomplete="off" spellcheck="true" type="text" show-cancel-button="focus">
54+
</ion-searchbar>
55+
5256
<h5 class="ion-padding-start ion-padding-top"> Search - Disabled </h5>
5357
<ion-searchbar id="disabled" value="disabled" type="text" disabled="true">
5458
</ion-searchbar>

core/src/components/searchbar/usage/angular.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
<!-- Searchbar with telephone type -->
2121
<ion-searchbar type="tel"></ion-searchbar>
2222

23+
<!-- Searchbar with numeric inputmode -->
24+
<ion-searchbar inputmode="numeric"></ion-searchbar>
25+
2326
<!-- Searchbar disabled -->
2427
<ion-searchbar disabled="true"></ion-searchbar>
2528

core/src/components/searchbar/usage/javascript.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
<!-- Searchbar with telephone type -->
2121
<ion-searchbar type="tel"></ion-searchbar>
2222

23+
<!-- Searchbar with numeric inputmode -->
24+
<ion-searchbar inputmode="numeric"></ion-searchbar>
25+
2326
<!-- Searchbar disabled -->
2427
<ion-searchbar disabled="true"></ion-searchbar>
2528

core/src/components/searchbar/usage/react.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ export const SearchbarExample: React.FunctionComponent = () => (
66
<IonContent>
77
{/*-- Default Searchbar --*/}
88
<IonSearchbar></IonSearchbar>
9-
9+
1010
{/*-- Searchbar with cancel button always shown --*/}
1111
<IonSearchbar showCancelButton="always"></IonSearchbar>
12-
12+
1313
{/*-- Searchbar with cancel button never shown --*/}
1414
<IonSearchbar showCancelButton="never"></IonSearchbar>
15-
15+
1616
{/*-- Searchbar with cancel button shown on focus --*/}
1717
<IonSearchbar showCancelButton="focus"></IonSearchbar>
1818

@@ -25,6 +25,9 @@ export const SearchbarExample: React.FunctionComponent = () => (
2525
{/*-- Searchbar with telephone type --*/}
2626
<IonSearchbar type="tel"></IonSearchbar>
2727

28+
{/*-- Searchbar with numeric inputmode --*/}
29+
<IonSearchbar inputmode="numeric"></IonSearchbar>
30+
2831
{/*-- Searchbar disabled --*/}
2932
<IonSearchbar disabled={true}></IonSearchbar>
3033

core/src/components/searchbar/usage/vue.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
<!-- Searchbar with telephone type -->
2222
<ion-searchbar type="tel"></ion-searchbar>
2323

24+
<!-- Searchbar with numeric inputmode -->
25+
<ion-searchbar inputmode="numeric"></ion-searchbar>
26+
2427
<!-- Searchbar disabled -->
2528
<ion-searchbar disabled="true"></ion-searchbar>
2629

0 commit comments

Comments
 (0)