diff --git a/docs/examples/debug.tsx b/docs/examples/debug.tsx index 4e21d24d9..d2e2fa478 100644 --- a/docs/examples/debug.tsx +++ b/docs/examples/debug.tsx @@ -146,8 +146,10 @@ export default () => { return (
+ +
- { console.error('1'); console.log('🎲 PanelValue Change:', panelValue, mode); }} - /> + /> */}
); diff --git a/src/PickerInput/Popup/index.tsx b/src/PickerInput/Popup/index.tsx index ee6dca74e..af4eb0f43 100644 --- a/src/PickerInput/Popup/index.tsx +++ b/src/PickerInput/Popup/index.tsx @@ -74,6 +74,7 @@ export default function Popup(props: PopupProps(null); const wrapperRef = React.useRef(null); // ======================== Offset ======================== @@ -90,10 +91,14 @@ export default function Popup(props: PopupProps(props: PopupProps
diff --git a/src/PickerInput/Selector/RangeSelector.tsx b/src/PickerInput/Selector/RangeSelector.tsx index be0927f38..4f5148926 100644 --- a/src/PickerInput/Selector/RangeSelector.tsx +++ b/src/PickerInput/Selector/RangeSelector.tsx @@ -174,7 +174,9 @@ function RangeSelector( const syncActiveOffset = useEvent(() => { const input = getInput(activeIndex); - if (input) { + if (activeIndex === 0) { + onActiveOffset(0); + } else if (input) { const { offsetWidth, offsetLeft, offsetParent } = input.nativeElement; let offset = offsetLeft; diff --git a/tests/range.spec.tsx b/tests/range.spec.tsx index 94712c3fb..010582054 100644 --- a/tests/range.spec.tsx +++ b/tests/range.spec.tsx @@ -1659,7 +1659,7 @@ describe('Picker.Range', () => { offsetWidth: { get() { if (this.className.includes('range-arrow')) { - return 14; + return 0; } else if (this.className.includes('panel-container')) { return 312; } else if (this.className.includes('input')) { @@ -1695,7 +1695,7 @@ describe('Picker.Range', () => { offsetWidth: { get() { if (this.className.includes('range-arrow')) { - return 14; + return 0; } else if (this.className.includes('panel-container')) { return 312; } else if (this.className.includes('input')) { @@ -1722,6 +1722,7 @@ describe('Picker.Range', () => { />, ); openPicker(container, 1); + console.log(document.querySelector('.rc-picker-panel-container').style.cssText); expect(document.querySelector('.rc-picker-panel-container')).toHaveStyle({ marginLeft: 0 }); mock.mockRestore(); });