Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
pointhalo committed Aug 20, 2024
2 parents 46f67b4 + d25c51d commit bf9815b
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 163 deletions.
15 changes: 15 additions & 0 deletions cypress/e2e/datePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,21 @@ describe('DatePicker', () => {
cy.get('.semi-input').eq(1).should('have.value', '2024-02-26');
});

it('fixed selected status bug when double click', () => {
cy.visit('http://localhost:6006/iframe.html?id=datepicker--fixed-selected-status&viewMode=story');
cy.get('.semi-input').eq(0).click();
cy.get('.semi-datepicker-month-grid-left .semi-datepicker-day').contains('15')
.then($day => {
$day.trigger('click');
});
cy.get('.semi-datepicker-day-selected').contains("15");
cy.get('.semi-datepicker-month-grid-left .semi-datepicker-day').contains('15')
.then($day => {
$day.trigger('click');
});
cy.get('.semi-datepicker-day-selected').contains("15");
})

it('fixed selected is not update when close panel', () => {
cy.visit('http://localhost:6006/iframe.html?id=datepicker--fixed-controlled&viewMode=story');
cy.get('.semi-input').eq(1).click();
Expand Down
7 changes: 3 additions & 4 deletions packages/semi-foundation/datePicker/monthsGridFoundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,11 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
const multiple = this._isMultiple();
const { selected } = this.getStates();
const monthDetail = this._getPanelDetail(panelType);
const newSelected = new Set(multiple ? [...selected] : []);
const newSelected = new Set<string>(multiple ? [...selected] : []);

const { fullDate } = day;
const time = monthDetail.pickerDate;
const dateStr = type === 'dateTime' ? this._mergeDateAndTime(fullDate, time) : fullDate;
const dateStr = fullDate;

if (!multiple) {
newSelected.add(dateStr);
Expand All @@ -631,9 +631,8 @@ export default class MonthsGridFoundation extends BaseFoundation<MonthsGridAdapt
}
}

const dateFormat = this.getValidDateFormat();
// When passed to the upper layer, it is converted into a Date object to ensure that the input parameter format of initFormDefaultValue is consistent
const newSelectedDates = [...newSelected].map(_dateStr => compatibleParse(_dateStr, dateFormat, undefined, dateFnsLocale));
const newSelectedDates = [...newSelected].map(_dateStr => type === 'dateTime' ? this._mergeDateAndTime(_dateStr, time) : compatibleParse(_dateStr, strings.FORMAT_FULL_DATE, undefined, dateFnsLocale));

this.handleShowDateAndTime(panelType, time);

Expand Down
1 change: 1 addition & 0 deletions packages/semi-ui/datePicker/_story/datePicker.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export {
FixNeedConfirmControlled,
FixedNaN,
PresetsFunctionType,
FixedSelectedStatus,
FixedControlled
} from './v2';

Expand Down
8 changes: 8 additions & 0 deletions packages/semi-ui/datePicker/_story/v2/FixedSelectedStatus.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import { DatePicker } from '@douyinfe/semi-ui';

const App = () => (
<DatePicker type="dateTime" defaultPickerValue="2022-07-01" />
);

export default App;
1 change: 1 addition & 0 deletions packages/semi-ui/datePicker/_story/v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export { default as AutoSplitInput } from './AutoSplitInput';
export { default as FixNeedConfirmControlled } from './FixNeedConfirmControlled';
export { default as PresetsFunctionType } from './PresetsFunctionType';
export { default as FixedNaN } from './FixedNaN';
export { default as FixedSelectedStatus } from './FixedSelectedStatus';
export { default as FixedControlled } from './FixedControlled';
5 changes: 4 additions & 1 deletion packages/semi-ui/table/Body/BaseRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,11 @@ export default class TableRow extends BaseComponent<BaseRowProps, Record<string,
// Only the first data row will be indented
if (level != null && columnIndex === firstIndex) {
expandableProps.indent = level;
const isBool = typeof expandIcon === 'boolean';
const hasExpandIcon = expandIcon !== false || !isBool && expandIcon !== null;

if (!expandableRow && hideExpandedColumn) {
// 如果 expandIcon 为空,不需要 indent
if (!expandableRow && hideExpandedColumn && hasExpandIcon) {
expandableProps.indent = level + 1;
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/semi-ui/table/_story/table.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ export {
DndKitDrag,
FixedOnGroupedRowClassName,
FixedVirtualizedRef,
RowSelectionOnCell
RowSelectionOnCell,
FixedIndent
} from './v2';
export { default as FixSelectAll325 } from './Demos/rowSelection';

Expand Down
54 changes: 54 additions & 0 deletions packages/semi-ui/table/_story/v2/FixedIndent/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React from 'react';
import { Table } from '@douyinfe/semi-ui';

export default function App() {
const columns = [
{
title: 'Key',
dataIndex: 'dataKey',
key: 'dataKey',
},
{
title: '名称',
dataIndex: 'name',
key: 'name',
width: 200,
},
{
title: '数据类型',
dataIndex: 'type',
key: 'type',
width: 400,
},
];
const data = [
{
key: 99,
dataKey: 99,
name: 'row 99',
children: [],
},
{
key: 2,
dataKey: 'text_info',
name: '文本信息',
type: 'Object 对象',
description: '视频的元信息',
default: '无',
children: [
{
key: 21,
dataKey: 'title',
name: '视频标题',
type: 'String 字符串',
description: '视频的标题',
default: '无',
},
],
},
];
return <div>
<Table expandIcon={false} defaultExpandAllRows columns={columns} dataSource={data} />
<Table defaultExpandAllRows columns={columns} dataSource={data} />
</div>;
}
1 change: 1 addition & 0 deletions packages/semi-ui/table/_story/v2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ export { default as DndKitDrag } from './DndKitDrag';
export { default as FixedOnGroupedRowClassName } from './FixedOnGroupedRowClassName';
export { default as FixedVirtualizedRef } from './FixedVirtualizedRef';
export { default as RowSelectionOnCell } from './RowSelectionOnCell';
export { default as FixedIndent } from './FixedIndent';
Loading

0 comments on commit bf9815b

Please sign in to comment.