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

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",
3
+ "version": "1.14.0-alpha.2",
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",
31
- "@gm-pc/table-x": "^1.13.3",
30
+ "@gm-pc/react": "^1.14.0-alpha.2",
31
+ "@gm-pc/table-x": "^1.14.0-alpha.2",
32
32
  "classnames": "^2.2.5",
33
33
  "lodash": "^4.17.19"
34
34
  },
35
- "gitHead": "647eed9642bb068bd166192f0a91978640f1108e"
35
+ "gitHead": "87c43be6d0db6959826af69c5dc13d26e10cba10"
36
36
  }
@@ -31,7 +31,7 @@ const KCInputNumber: ForwardRefRenderFunction<RefFunctionProps, InputNumberProps
31
31
 
32
32
  const handleFocus = () => {
33
33
  // eslint-disable-next-line
34
- targetRef.current?.apiDoFocus()
34
+ targetRef.current?.apiDoSelect()
35
35
  }
36
36
 
37
37
  const handleInputFocus = (event: FocusEvent<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
@@ -27,8 +27,6 @@ function scrollIntoViewFixedWidth(
27
27
  scrollLeft
28
28
  ) {
29
29
  table.scrollLeft = offsetLeft + offsetWidth - (table.offsetWidth - rightFixedWidth)
30
- } else {
31
- table.scrollLeft = 0
32
30
  }
33
31
 
34
32
  // 只 tablex 生效
@@ -44,7 +42,7 @@ function scrollIntoViewFixedWidth(
44
42
  export default scrollIntoViewFixedWidth
45
43
 
46
44
  function getTd(dom: HTMLElement) {
47
- let parentNode = dom.parentNode as HTMLElement
45
+ let parentNode = dom?.parentNode as HTMLElement
48
46
  while (
49
47
  !(
50
48
  parentNode.classList.contains('rt-td') ||
@@ -59,7 +57,7 @@ function getTd(dom: HTMLElement) {
59
57
  }
60
58
 
61
59
  function getTable(dom: HTMLElement) {
62
- let parentNode = dom.parentNode as HTMLElement
60
+ let parentNode = dom?.parentNode as HTMLElement
63
61
  while (
64
62
  !(
65
63
  parentNode.classList.contains('gm-table-x') ||