@@ -3,6 +3,8 @@ import _ from "lodash";
3
3
import config from "stock/config/environment" ;
4
4
import SearchMixin from "stock/mixins/search_resource" ;
5
5
import AsyncMixin from "stock/mixins/async" ;
6
+ import { chain } from "../../utils/async" ;
7
+ import { callbackObserver } from "../../utils/ember" ;
6
8
7
9
export default Ember . Component . extend ( SearchMixin , AsyncMixin , {
8
10
searchText : "" ,
@@ -12,13 +14,27 @@ export default Ember.Component.extend(SearchMixin, AsyncMixin, {
12
14
perPage : 10 ,
13
15
isMobileApp : config . cordova . enabled ,
14
16
packageService : Ember . inject . service ( ) ,
17
+ cordova : Ember . inject . service ( ) ,
15
18
messageBox : Ember . inject . service ( ) ,
16
19
i18n : Ember . inject . service ( ) ,
20
+ requireFocus : false ,
21
+
22
+ inputmode : Ember . computed ( "searchMode" , function ( ) {
23
+ if ( this . get ( "searchMode" ) === "numeric" ) {
24
+ return "numeric" ;
25
+ }
26
+ return "text" ;
27
+ } ) ,
17
28
18
29
hasSearchText : Ember . computed ( "searchText" , function ( ) {
19
30
return ! ! this . get ( "searchText" ) ;
20
31
} ) ,
21
32
33
+ openStateListener : callbackObserver ( "open" , [
34
+ [ true , "onOpen" ] ,
35
+ [ false , "onClose" ]
36
+ ] ) ,
37
+
22
38
closeOverlay ( ) {
23
39
this . setProperties ( {
24
40
searchText : "" ,
@@ -38,6 +54,20 @@ export default Ember.Component.extend(SearchMixin, AsyncMixin, {
38
54
return _ . flatten ( [ states ] ) . join ( "," ) ;
39
55
} ,
40
56
57
+ async onOpen ( ) {
58
+ const platform = this . get ( "cordova" ) ;
59
+ const scrollFix = platform . isIOS ( ) || platform . isIOSBrowser ( ) ;
60
+
61
+ await chain . stagerred ( [
62
+ ( ) => this . set ( "requireFocus" , true ) ,
63
+ ( ) => scrollFix && window . scrollTo ( 0 , 0 )
64
+ ] ) ;
65
+ } ,
66
+
67
+ onClose ( ) {
68
+ this . set ( "requireFocus" , false ) ;
69
+ } ,
70
+
41
71
actions : {
42
72
cancel ( ) {
43
73
this . closeOverlay ( ) ;
0 commit comments