Skip to content

Commit 354b722

Browse files
author
chenbiao
committed
fix: Fix Popup localization issue when NeedConfirm=false
1 parent 08fd30a commit 354b722

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

docs/examples/range.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,19 @@ export default () => {
213213
disabledDate={disabledDate}
214214
/>
215215
</div>
216+
<div>
217+
<h3>needConfirm is false</h3>
218+
<RangePicker<Moment>
219+
{...sharedProps}
220+
value={undefined}
221+
locale={zhCN}
222+
needConfirm={false}
223+
picker="time"
224+
ranges={{
225+
test: [moment(), moment().add(1, 'hour')],
226+
}}
227+
/>
228+
</div>
216229
</div>
217230
</div>
218231
);

src/PickerInput/Popup/index.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export interface PopupProps<DateType extends object = any, PresetValue = DateTyp
3434
activeInfo?: [activeInputLeft: number, activeInputRight: number, selectorWidth: number];
3535
// Direction
3636
direction?: 'ltr' | 'rtl';
37+
// focus index
38+
index: number;
3739

3840
// Fill
3941
/** TimePicker or showTime only */
@@ -58,7 +60,7 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
5860
range,
5961
multiple,
6062
activeInfo = [0, 0, 0],
61-
63+
index = 0,
6264
// Presets
6365
presets,
6466
onPresetHover,
@@ -80,7 +82,6 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
8082
onOk,
8183
onSubmit,
8284
} = props;
83-
8485
const { prefixCls } = React.useContext(PickerContext);
8586
const panelPrefixCls = `${prefixCls}-panel`;
8687

@@ -118,7 +119,8 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
118119
// Arrow Offset
119120
const wrapperRect = wrapperRef.current.getBoundingClientRect();
120121
if (!wrapperRect.height || wrapperRect.right < 0) {
121-
setRetryTimes((times) => Math.max(0, times - 1));
122+
// Index is designed to be compatible with the bug of inconsistency between React 18 useEffect and React 19
123+
setRetryTimes((times) => Math.max(0, times - index - 1));
122124
return;
123125
}
124126

@@ -138,7 +140,16 @@ export default function Popup<DateType extends object = any>(props: PopupProps<D
138140
setContainerOffset(0);
139141
}
140142
}
141-
}, [retryTimes, rtl, containerWidth, activeInputLeft, activeInputRight, selectorWidth, range]);
143+
}, [
144+
retryTimes,
145+
rtl,
146+
containerWidth,
147+
activeInputLeft,
148+
activeInputRight,
149+
selectorWidth,
150+
range,
151+
index,
152+
]);
142153

143154
// ======================== Custom ========================
144155
function filterEmpty<T>(list: T[]) {

src/PickerInput/RangePicker.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ function RangePicker<DateType extends object = any>(
592592
range
593593
multiplePanel={multiplePanel}
594594
activeInfo={activeInfo}
595+
index={activeIndex}
595596
// Disabled
596597
disabledDate={mergedDisabledDate}
597598
// Focus

0 commit comments

Comments
 (0)