Browse Source

fix: convert item.value to item.month to ensure that the datepicker can compare the correct numbers instead of letters in monthRange (#2871)

* fix: convert item.value to item.month to ensure that the datepicker can compare the correct numbers instead of letters in monthRange

* fix: convert item.value to item.month to ensure that the datepicker can compare the correct numbers instead of letters in monthRange
YannLynn 4 months ago
parent
commit
9176c05534

+ 1 - 1
packages/semi-foundation/datePicker/yearAndMonthFoundation.ts

@@ -106,7 +106,7 @@ export default class YearAndMonthFoundation extends BaseFoundation<YearAndMonthA
         month[panelType] = item.month;
 
         // Make sure the time on the right panel is always greater than or equal to the time on the left panel
-        if (type === 'monthRange' && panelType === left && currentYear[left] === currentYear[right] && item.value > month[right]) {
+        if (type === 'monthRange' && panelType === left && currentYear[left] === currentYear[right] && item.month > month[right]) {
             month[right] = item.month ;
         } 
 

+ 3 - 0
packages/semi-ui/locale/_story/locale.stories.jsx

@@ -173,6 +173,9 @@ const I18nComponent = () => {
                 <p>This is the content of a basic modal.</p>
                 <p>More content...</p>
             </Modal>
+            <div>
+                <DatePicker type="monthRange" onChange={(date, dateString) => console.log(dateString)} />
+            </div>
             <div>
               <DatePicker style={{ ...style, width: 200 }} open defaultPickerValue={[new Date('2024-09-08 00:00'), new Date('2024-09-09 12:00')]} />
               <DatePicker style={{ ...style,marginLeft:120, width: 250 }} open type="dateTime" presets={presets} presetPosition="left" defaultPickerValue={[new Date('2024-09-08 00:00'), new Date('2024-09-09 12:00')]} />