mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
fix: table column 快捷操作同时支持 sortable 和一个非 sortable 的操作组合 (#5341)
This commit is contained in:
parent
54641d2e80
commit
9da3c98330
@ -865,3 +865,50 @@ test('Renderer:crud group', async () => {
|
||||
).getAttribute('rowSpan')
|
||||
).toBe('2');
|
||||
});
|
||||
|
||||
test('Renderer: crud searchable sortable filterable', async () => {
|
||||
const mockFetcher = jest.fn(fetcher);
|
||||
const {container, debug, getByText} = render(
|
||||
amisRender(
|
||||
{
|
||||
type: 'page',
|
||||
body: {
|
||||
type: 'crud',
|
||||
api: '/api/mock2/sample',
|
||||
syncLocation: false,
|
||||
columns: [
|
||||
{
|
||||
name: '__id',
|
||||
label: 'ID'
|
||||
},
|
||||
{
|
||||
name: 'engine',
|
||||
label: 'Rendering engine',
|
||||
quickEdit: true,
|
||||
sortable: true,
|
||||
searchable: true,
|
||||
options: ['1', '2', '3']
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{},
|
||||
makeEnv({fetcher: mockFetcher})
|
||||
)
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(container.querySelectorAll('tbody>tr').length > 5).toBeTruthy();
|
||||
});
|
||||
|
||||
expect(container.querySelector('[icon="filter"]')).not.toBeInTheDocument();
|
||||
|
||||
fireEvent.click(container.querySelector('[icon="search"]')!);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(container.querySelector('.cxd-PopOver')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// 弹窗中没有 排序
|
||||
expect(container.querySelectorAll('[data-role="form-item"]').length).toBe(1);
|
||||
});
|
||||
|
@ -1893,16 +1893,16 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
);
|
||||
}
|
||||
|
||||
let affix = null;
|
||||
let affix = [];
|
||||
|
||||
if (column.searchable && column.name && !autoGenerateFilter) {
|
||||
affix = (
|
||||
affix.push(
|
||||
<HeadCellSearchDropDown
|
||||
{...this.props}
|
||||
onQuery={onQuery}
|
||||
name={column.name}
|
||||
searchable={column.searchable}
|
||||
sortable={column.sortable}
|
||||
sortable={false}
|
||||
type={column.type}
|
||||
data={query}
|
||||
orderBy={store.orderBy}
|
||||
@ -1910,8 +1910,9 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
popOverContainer={this.getPopOverContainer}
|
||||
/>
|
||||
);
|
||||
} else if (column.sortable && column.name) {
|
||||
affix = (
|
||||
}
|
||||
if (column.sortable && column.name) {
|
||||
affix.push(
|
||||
<span
|
||||
className={cx('TableCell-sortBtn')}
|
||||
onClick={async () => {
|
||||
@ -1979,8 +1980,9 @@ export default class Table extends React.Component<TableProps, object> {
|
||||
</i>
|
||||
</span>
|
||||
);
|
||||
} else if (column.filterable && column.name) {
|
||||
affix = (
|
||||
}
|
||||
if (!column.searchable && column.filterable && column.name) {
|
||||
affix.push(
|
||||
<HeadCellFilterDropDown
|
||||
{...this.props}
|
||||
onQuery={onQuery}
|
||||
|
Loading…
Reference in New Issue
Block a user