@gm-pc/keyboard 1.13.3-alpha.2 → 1.14.0-alpha.1

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/keyboard",
3
- "version": "1.13.3-alpha.2",
3
+ "version": "1.14.0-alpha.1",
4
4
  "description": "",
5
5
  "author": "liyatang <liyatang@qq.com>",
6
6
  "homepage": "https://github.com/gmfe/gm-pc#readme",
@@ -27,10 +27,10 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@gm-common/tool": "^2.10.0",
30
- "@gm-pc/react": "^1.13.3-alpha.2",
31
- "@gm-pc/table-x": "^1.13.3-alpha.2",
30
+ "@gm-pc/react": "^1.14.0-alpha.1",
31
+ "@gm-pc/table-x": "^1.14.0-alpha.1",
32
32
  "classnames": "^2.2.5",
33
33
  "lodash": "^4.17.19"
34
34
  },
35
- "gitHead": "bdd278fe8bf983b735b760af20581ab580972632"
35
+ "gitHead": "b8a3ea89e8e45c98d6706b52ca05c6f4bf4bef68"
36
36
  }
@@ -35,11 +35,14 @@ const KCInputNumber: ForwardRefRenderFunction<RefFunctionProps, InputNumberProps
35
35
  }
36
36
 
37
37
  const handleInputFocus = (event: FocusEvent<HTMLInputElement>) => {
38
+ event.persist()
38
39
  if (onFocus) {
39
40
  onFocus(event)
40
41
  return
41
42
  }
42
- event.target && event.target.select()
43
+ setTimeout(() => {
44
+ event.target && event.target.select()
45
+ })
43
46
  }
44
47
 
45
48
  const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
package/src/core/wrap.tsx CHANGED
@@ -96,6 +96,8 @@ const Wrap: FC<WrapProps> = ({
96
96
  columnKeys[0],
97
97
  cellKey
98
98
  )
99
+ const table = document.querySelector('.gm-table-x')
100
+ if (table) table.scrollLeft = 0
99
101
  }, 10)
100
102
  }
101
103
  }
@@ -76,17 +76,28 @@ function keyboardTableXHOC<Props extends TableXProps = TableXProps>(
76
76
  // fix hoc 带来的问题
77
77
  let leftFixedWidth = 0
78
78
  let rightFixedWidth = 0
79
- useMemo(() => {
80
- columns.forEach((column: KeyboardTableXColumn) => {
81
- if (column.show !== false) {
82
- if (column.fixed === 'left' && column.width) {
83
- leftFixedWidth += column.width as number
84
- } else if (column.fixed === 'right' && column.width) {
85
- rightFixedWidth += column.width as number
86
- }
79
+ // useMemo(() => {
80
+ // columns.forEach((column: KeyboardTableXColumn) => {
81
+ // if (column.show !== false) {
82
+ // if (column.fixed === 'left' && column.width) {
83
+ // leftFixedWidth += column.width as number
84
+ // } else if (column.fixed === 'right' && column.width) {
85
+ // rightFixedWidth += column.width as number
86
+ // }
87
+ // }
88
+ // })
89
+ // }, [columns])
90
+
91
+ // 这里缓存的话,会导致keyboardleft时滚动条无法跟随焦点走
92
+ columns.forEach((column: KeyboardTableXColumn) => {
93
+ if (column.show !== false) {
94
+ if (column.fixed === 'left' && column.width) {
95
+ leftFixedWidth += column.width as number
96
+ } else if (column.fixed === 'right' && column.width) {
97
+ rightFixedWidth += column.width as number
87
98
  }
88
- })
89
- }, [columns])
99
+ }
100
+ })
90
101
 
91
102
  return (
92
103
  <Wrap
@@ -42,7 +42,7 @@ function scrollIntoViewFixedWidth(
42
42
  export default scrollIntoViewFixedWidth
43
43
 
44
44
  function getTd(dom: HTMLElement) {
45
- let parentNode = dom.parentNode as HTMLElement
45
+ let parentNode = dom?.parentNode as HTMLElement
46
46
  while (
47
47
  !(
48
48
  parentNode.classList.contains('rt-td') ||
@@ -57,7 +57,7 @@ function getTd(dom: HTMLElement) {
57
57
  }
58
58
 
59
59
  function getTable(dom: HTMLElement) {
60
- let parentNode = dom.parentNode as HTMLElement
60
+ let parentNode = dom?.parentNode as HTMLElement
61
61
  while (
62
62
  !(
63
63
  parentNode.classList.contains('gm-table-x') ||