File tree Expand file tree Collapse file tree 3 files changed +45
-6
lines changed Expand file tree Collapse file tree 3 files changed +45
-6
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ export default () => {
6969 allowClear
7070 ref = { rangePickerRef }
7171 showTime
72- style = { { width : 700 } }
72+ style = { { width : 580 } }
7373 ranges = { {
7474 ranges : [ moment ( ) , moment ( ) . add ( 10 , 'day' ) ] ,
7575 } }
Original file line number Diff line number Diff line change @@ -894,16 +894,19 @@ function InnerRangePicker<DateType>(props: RangePickerProps<DateType>) {
894894 arrowLeft = startInputDivRef . current . offsetWidth + separatorRef . current . offsetWidth ;
895895
896896 // If panelWidth - arrowWidth - arrowMarginLeft < arrowLeft, panel should move to right side.
897- // If offsetLeft > arrowLeft, arrow position is absolutely right, because arrowLeft is not calculated with arrow margin.
897+ // If arrowOffsetLeft > arrowLeft, arrowMarginLeft = arrowOffsetLeft - arrowLeft
898+ const arrowMarginLeft =
899+ arrowRef . current . offsetLeft > arrowLeft
900+ ? arrowRef . current . offsetLeft - arrowLeft
901+ : arrowRef . current . offsetLeft ;
902+
898903 if (
899904 panelDivRef . current . offsetWidth &&
900905 arrowRef . current . offsetWidth &&
901906 arrowLeft >
902907 panelDivRef . current . offsetWidth -
903908 arrowRef . current . offsetWidth -
904- ( direction === 'rtl' || arrowRef . current . offsetLeft > arrowLeft
905- ? 0
906- : arrowRef . current . offsetLeft )
909+ ( direction === 'rtl' ? 0 : arrowMarginLeft )
907910 ) {
908911 panelLeft = arrowLeft ;
909912 }
Original file line number Diff line number Diff line change @@ -1589,7 +1589,7 @@ describe('Picker.Range', () => {
15891589 mock . mockRestore ( ) ;
15901590 } ) ;
15911591
1592- it ( 'panel should be stable: right' , ( ) => {
1592+ it ( 'panel should be stable: arrow right and panel left ' , ( ) => {
15931593 const mock = spyElementPrototypes ( HTMLElement , {
15941594 offsetWidth : {
15951595 get ( ) {
@@ -1624,4 +1624,40 @@ describe('Picker.Range', () => {
16241624 expect ( wrapper . find ( '.rc-picker-panel-container' ) . getDOMNode ( ) . style . marginLeft ) . toBe ( '0px' ) ;
16251625 mock . mockRestore ( ) ;
16261626 } ) ;
1627+
1628+ it ( 'panel should be stable: arrow right and panel right' , ( ) => {
1629+ const mock = spyElementPrototypes ( HTMLElement , {
1630+ offsetWidth : {
1631+ get ( ) {
1632+ if ( this . className . includes ( 'range-arrow' ) ) {
1633+ return 14 ;
1634+ } else if ( this . className . includes ( 'panel-container' ) ) {
1635+ return 311 ;
1636+ } else if ( this . className . includes ( 'input' ) ) {
1637+ return 285 ;
1638+ } else if ( this . className . includes ( 'range-separator' ) ) {
1639+ return 10 ;
1640+ }
1641+ } ,
1642+ } ,
1643+ offsetLeft : {
1644+ get ( ) {
1645+ if ( this . className . includes ( 'range-arrow' ) ) {
1646+ return 305 ;
1647+ }
1648+ } ,
1649+ } ,
1650+ } ) ;
1651+ const wrapper = mount (
1652+ < MomentRangePicker
1653+ allowClear
1654+ defaultValue = { [ moment ( '1990-09-03' ) , moment ( '1989-11-28' ) ] }
1655+ clearIcon = { < span > X</ span > }
1656+ suffixIcon = { < span > O</ span > }
1657+ /> ,
1658+ ) ;
1659+ wrapper . openPicker ( 1 ) ;
1660+ expect ( wrapper . find ( '.rc-picker-panel-container' ) . getDOMNode ( ) . style . marginLeft ) . toBe ( '295px' ) ;
1661+ mock . mockRestore ( ) ;
1662+ } ) ;
16271663} ) ;
You can’t perform that action at this time.
0 commit comments