@gm-pc/react 1.17.0-beta.4 → 1.17.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gm-pc/react",
3
- "version": "1.17.0-beta.4",
3
+ "version": "1.17.0-beta.8",
4
4
  "description": "观麦前端基础组件库",
5
5
  "author": "liyatang <liyatang@qq.com>",
6
6
  "homepage": "https://github.com/gmfe/gm-pc#readme",
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@gm-common/hooks": "^2.10.0",
26
26
  "@gm-common/tool": "^2.10.0",
27
- "@gm-pc/locales": "^1.17.0-beta.4",
27
+ "@gm-pc/locales": "^1.17.0-beta.8",
28
28
  "big.js": "^6.0.1",
29
29
  "classnames": "^2.2.5",
30
30
  "lodash": "^4.17.19",
@@ -48,5 +48,5 @@
48
48
  "react-router-dom": "^5.2.0",
49
49
  "react-window": "^1.8.5"
50
50
  },
51
- "gitHead": "9a9c98bba54ce73bdc07dc3023a5fece1980f8ea"
51
+ "gitHead": "8a04790de682b7a6ef9187d8434c8c8a535bea63"
52
52
  }
@@ -82,6 +82,7 @@ const AutoComplete = forwardRef<AutoCompleteRef, AutoCompleteProps>((props, ref)
82
82
  const inputNode = useRef<HTMLInputElement | null>(null)
83
83
 
84
84
  const triggerPopover = (value: boolean) => {
85
+ if (value === true && options.length <= 0) return
85
86
  popoverNode.current && popoverNode.current.apiDoSetActive(value)
86
87
  }
87
88
 
@@ -97,13 +98,21 @@ const AutoComplete = forwardRef<AutoCompleteRef, AutoCompleteProps>((props, ref)
97
98
  }, [value, options])
98
99
 
99
100
  const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
100
- if (!popoverVisible.current) {
101
+ if (event.key === 'Enter') {
102
+ triggerPopover(false)
103
+ if (willActiveIndex >= 0) {
104
+ const val = options[willActiveIndex]?.value
105
+ if (!_.isNil(val) && value !== val) {
106
+ onChange && onChange(val)
107
+ return
108
+ }
109
+ }
101
110
  onKeyDown && onKeyDown(event)
102
111
  return
103
112
  }
104
- if (event.key === 'Enter') {
105
- onChange && onChange(options[willActiveIndex].value)
106
- triggerPopover(false)
113
+ if (!popoverVisible.current) {
114
+ onKeyDown && onKeyDown(event)
115
+ return
107
116
  }
108
117
  if (event.key === 'Escape') {
109
118
  triggerPopover(false)
@@ -177,9 +186,7 @@ const AutoComplete = forwardRef<AutoCompleteRef, AutoCompleteProps>((props, ref)
177
186
  value={value}
178
187
  onChange={(e) => {
179
188
  const val = e.target.value
180
- if (val.length === 0) {
181
- triggerPopover(true)
182
- }
189
+ triggerPopover(val.length === 0)
183
190
  onChange && onChange(val)
184
191
  }}
185
192
  onBlur={(e) => {