Skip to content

Commit c176e8d

Browse files
committed
fix: fixed table issues
1 parent eb12feb commit c176e8d

File tree

23 files changed

+152
-439
lines changed

23 files changed

+152
-439
lines changed

component/packages/wu-select-option/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class WuSelectOptions extends WuComponent implements OnConnected {
2222
public disabled: string;
2323

2424
@Prop({ default: true, type: Boolean })
25-
public visible: boolean = true;
25+
public visible = true;
2626

2727
@Prop({ default: '' })
2828
public value: string;

component/packages/wu-table/public/index.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,17 @@
66
</head>
77
<body>
88
<div id="app">
9-
<wu-test-example></wu-test-example>
9+
<div style="display: flex; align-items: center;justify-content: center;width: 100%; margin-top: 8px; margin-bottom: 16px">
10+
<wu-plus-table
11+
checkbox="true"
12+
stripe="false"
13+
border="true"
14+
compact="false"
15+
data='[{"id":1,"name":"xwang","age":18,"address":"是是是"}]'
16+
columns='[{"title":"ID","key":"id","align":"center"},{"title":"Name","align":"center","key":"name"},{"title":"age","key":"age"},{"title":"address","key":"address"}]'
17+
></wu-plus-table>
18+
19+
</div>
1020
</div>
1121
</body>
1222
</html>

component/packages/wu-table/src/index.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Emit, h, OnBeforeRender, OnConnected, Prop, WuComponent } from '@wu-component/web-core-plus';
1+
import { Component, Emit, h, OnBeforeRender, OnConnected, Prop, WuComponent, Fragment } from '@wu-component/web-core-plus';
22
import '@wu-component/wu-checkbox';
33
import '@wu-component/wu-input';
44
import css from './index.scss';
@@ -27,9 +27,9 @@ export class WuTable extends WuComponent implements OnConnected, OnBeforeRender
2727
* @private
2828
*/
2929
private setFixedLeft() {
30-
if (this.rootNode) {
31-
const fixedLeftEls = this.rootNode.querySelectorAll('.fixed-left');
32-
const boxRect = this.rootNode.getBoundingClientRect();
30+
if (this.shadowRoot) {
31+
const fixedLeftEls = this.shadowRoot.querySelectorAll('.fixed-left');
32+
const boxRect = this.shadowRoot.querySelector('.wu-table').getBoundingClientRect();
3333
fixedLeftEls.forEach((fixedLeftEl: HTMLElement, index: number) => {
3434
const rect = fixedLeftEl.getBoundingClientRect();
3535
fixedLeftEl.style.left = rect.left - boxRect.left - 1 + 'px';
@@ -42,7 +42,7 @@ export class WuTable extends WuComponent implements OnConnected, OnBeforeRender
4242
* @private
4343
*/
4444
private setFixedRight() {
45-
if (this.rootNode) {
45+
if (this.shadowRoot) {
4646
const fixedRightEls = this.shadowRoot.querySelectorAll('.fixed-right');
4747
fixedRightEls.forEach((fixedRightEl: HTMLElement, index: number) => {
4848
fixedRightEl.style.right = '0px';
@@ -186,7 +186,9 @@ export class WuTable extends WuComponent implements OnConnected, OnBeforeRender
186186
}
187187

188188
public override render(_renderProps = {}, _store = {}) {
189-
if (!this.columns.length) return;
189+
if (!this.columns.length) {
190+
return <Fragment></Fragment>;
191+
}
190192
if (this.fixedRight) {
191193
this.columns[this.columns.length - 1].fixed = true;
192194
}
@@ -223,6 +225,7 @@ export class WuTable extends WuComponent implements OnConnected, OnBeforeRender
223225
'wu-table-column-selection': column.type && column.selection === 'selection',
224226
})}
225227
>
228+
{/*@ts-ignore*/}
226229
<div class="cell">{column.type && column.type === 'selection' ? <wu-plus-checkbox checked={false} {...this.getCheckedState()} onChange={_ => this.changeHandlerTh(_, column, { isAllSelect: true })} /> : <div class="cell">{column.title}</div>}</div>
227230
</th>
228231
);
@@ -259,10 +262,12 @@ export class WuTable extends WuComponent implements OnConnected, OnBeforeRender
259262
>
260263
{column.type && column.type === 'selection' ? (
261264
<div class="cell">
265+
{/*@ts-ignore*/}
262266
<wu-plus-checkbox checked={item.checked} onChange={_ => this.changeHandlerTd(_, item, { isAllSelect: false })} />
263267
</div>
264268
) : column.editable && item.editingKey === column.key ? (
265269
<div class="cell">
270+
{/*@ts-ignore*/}
266271
<wu-plus-input ref={_ => (this.editingInput = _)} size="mini" onChange={evt => this.onChange(evt, item, column)} value={item[column.key]} />
267272
</div>
268273
) : (

0 commit comments

Comments
 (0)