diff --git a/cypress/e2e/timePicker.spec.js b/cypress/e2e/timePicker.spec.js index e144262a61..ec2f25f172 100644 --- a/cypress/e2e/timePicker.spec.js +++ b/cypress/e2e/timePicker.spec.js @@ -61,4 +61,13 @@ describe('timePicker', () => { cy.get('body').click('right'); cy.get('.semi-input-default').eq(1).should('have.value', '10:24:18'); }); + + it('timezone + disabledHours', () => { + cy.visit('http://127.0.0.1:6006/iframe.html?id=timepicker--fix-2082&args=&viewMode=story'); + cy.get('.semi-input-default').eq(0).click(); + cy.get('.semi-timepicker-panel-list-hour').eq(0).contains('07').click({ force: true }); + cy.get('.semi-timepicker-panel-list-minute').eq(0).contains('10').click({ force: true }); + cy.get('body').click('right'); + cy.get('.semi-input-default').eq(0).should('have.value', '07:10'); + }); }); \ No newline at end of file diff --git a/packages/semi-foundation/timePicker/foundation.ts b/packages/semi-foundation/timePicker/foundation.ts index ba715294ec..4341540b25 100644 --- a/packages/semi-foundation/timePicker/foundation.ts +++ b/packages/semi-foundation/timePicker/foundation.ts @@ -202,8 +202,8 @@ class TimePickerFoundation

, S = Record> ext const { value, timeZone, __prevTimeZone } = props; let dates = this.parseValue(value); - const invalid = this.validateDates(dates); + let invalid = dates.some(d => isNaN(Number(d))); if (!invalid) { if (this.isValidTimeZone(timeZone)) { dates = dates.map(date => @@ -213,6 +213,9 @@ class TimePickerFoundation

, S = Record> ext ) ); } + invalid = dates.some(d => + this.isDisabledHMS({ hours: d.getHours(), minutes: d.getMinutes(), seconds: d.getSeconds() }) + ); } const inputValue = this.formatValue(dates); diff --git a/packages/semi-ui/timePicker/_story/timepicker.stories.jsx b/packages/semi-ui/timePicker/_story/timepicker.stories.jsx index 91ecbff431..abf3d2d6e0 100644 --- a/packages/semi-ui/timePicker/_story/timepicker.stories.jsx +++ b/packages/semi-ui/timePicker/_story/timepicker.stories.jsx @@ -1,6 +1,6 @@ import React, { Component, useState } from 'react'; import TimePickerPanel from '../index'; -import { TimePicker as BasicTimePicker, Button, Form, Popover } from '../../index'; +import { TimePicker as BasicTimePicker, Button, Form, Popover, ConfigProvider } from '../../index'; import { strings } from '@douyinfe/semi-foundation/timePicker/constants'; import { get } from 'lodash'; @@ -356,3 +356,22 @@ export const Fix1953 = () => { ); }; + +export const Fix2082 = () => { + const [date, setDate] = useState(new Date()); + return ( + +

+
TimePicker:
+ [5]} + format="HH:mm" + value={date} + onChange={(date, dateString) => { + console.log('日期', date); + setDate(date)} } + /> +
+ + ); +}; \ No newline at end of file