File tree Expand file tree Collapse file tree 6 files changed +59
-5
lines changed
Expand file tree Collapse file tree 6 files changed +59
-5
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import slugify from "slugify";
55import CodeExampleComponent from "../Example" ;
66
77import Default from "../../examples/default" ;
8+ import NoAnchorArrow from "../../examples/noAnchorArrow" ;
89import ShowTime from "../../examples/showTime" ;
910import ShowTimeOnly from "../../examples/showTimeOnly" ;
1011import ExcludeTimes from "../../examples/excludeTimes" ;
@@ -78,6 +79,10 @@ export default class exampleComponents extends React.Component {
7879 title : "Default" ,
7980 component : Default
8081 } ,
82+ {
83+ title : "No Anchor Arrow" ,
84+ component : NoAnchorArrow
85+ } ,
8186 {
8287 title : "Select Time" ,
8388 component : ShowTime
Original file line number Diff line number Diff line change 1+ ( ) => {
2+ const [ startDate , setStartDate ] = useState ( new Date ( ) ) ;
3+ return (
4+ < DatePicker
5+ showPopperArrow = { false }
6+ selected = { startDate }
7+ onChange = { date => setStartDate ( date ) }
8+ />
9+ ) ;
10+ } ;
Original file line number Diff line number Diff line change @@ -127,7 +127,8 @@ export default class Calendar extends React.Component {
127127 renderCustomHeader : PropTypes . func ,
128128 renderDayContents : PropTypes . func ,
129129 onDayMouseEnter : PropTypes . func ,
130- onMonthMouseLeave : PropTypes . func
130+ onMonthMouseLeave : PropTypes . func ,
131+ showPopperArrow : PropTypes . bool
131132 } ;
132133
133134 static get defaultProps ( ) {
@@ -715,6 +716,7 @@ export default class Calendar extends React.Component {
715716 className = { classnames ( "react-datepicker" , this . props . className , {
716717 "react-datepicker--time-only" : this . props . showTimeSelectOnly
717718 } ) }
719+ showPopperArrow = { this . props . showPopperArrow }
718720 >
719721 { this . renderPreviousButton ( ) }
720722 { this . renderNextButton ( ) }
Original file line number Diff line number Diff line change @@ -4,11 +4,14 @@ import React from "react";
44export default function CalendarContainer ( {
55 className,
66 children,
7+ showPopperArrow,
78 arrowProps = { }
89} ) {
910 return (
1011 < div className = { className } >
11- < div className = "react-datepicker__triangle" { ...arrowProps } />
12+ { showPopperArrow && (
13+ < div className = "react-datepicker__triangle" { ...arrowProps } />
14+ ) }
1215 { children }
1316 </ div >
1417 ) ;
@@ -17,5 +20,6 @@ export default function CalendarContainer({
1720CalendarContainer . propTypes = {
1821 className : PropTypes . string ,
1922 children : PropTypes . node ,
20- arrowProps : PropTypes . object // react-popper arrow props
23+ arrowProps : PropTypes . object , // react-popper arrow props
24+ showPopperArrow : PropTypes . bool
2125} ;
Original file line number Diff line number Diff line change @@ -169,7 +169,8 @@ export default class DatePicker extends React.Component {
169169 wrapperClassName : PropTypes . string ,
170170 inlineFocusSelectedMonth : PropTypes . bool ,
171171 onDayMouseEnter : PropTypes . func ,
172- onMonthMouseLeave : PropTypes . func
172+ onMonthMouseLeave : PropTypes . func ,
173+ showPopperArrow : PropTypes . bool
173174 } ;
174175
175176 static get defaultProps ( ) {
@@ -211,7 +212,8 @@ export default class DatePicker extends React.Component {
211212 renderDayContents ( date ) {
212213 return date ;
213214 } ,
214- inlineFocusSelectedMonth : false
215+ inlineFocusSelectedMonth : false ,
216+ showPopperArrow : true
215217 } ;
216218 }
217219
@@ -697,6 +699,7 @@ export default class DatePicker extends React.Component {
697699 showTimeInput = { this . props . showTimeInput }
698700 showMonthYearPicker = { this . props . showMonthYearPicker }
699701 showQuarterYearPicker = { this . props . showQuarterYearPicker }
702+ showPopperArrow = { this . props . showPopperArrow }
700703 >
701704 { this . props . children }
702705 </ WrappedCalendar >
Original file line number Diff line number Diff line change @@ -1179,4 +1179,34 @@ describe("DatePicker", () => {
11791179 TestUtils . Simulate . click ( dayButtonInline ) ;
11801180 assert . equal ( datePickerInline . state . monthSelectedIn , undefined ) ;
11811181 } ) ;
1182+
1183+ it ( "should show the popper arrow when showPopperArrow is true" , ( ) => {
1184+ const datePicker = TestUtils . renderIntoDocument (
1185+ < DatePicker showPopperArrow />
1186+ ) ;
1187+ const dateInput = datePicker . input ;
1188+ TestUtils . Simulate . click ( ReactDOM . findDOMNode ( dateInput ) ) ;
1189+
1190+ const arrow = TestUtils . scryRenderedDOMComponentsWithClass (
1191+ datePicker . calendar ,
1192+ "react-datepicker__triangle"
1193+ ) ;
1194+
1195+ expect ( arrow ) . to . not . be . empty ;
1196+ } ) ;
1197+
1198+ it ( "should not show the popper arrow when showPopperArrow is false" , ( ) => {
1199+ const datePicker = TestUtils . renderIntoDocument (
1200+ < DatePicker showPopperArrow = { false } />
1201+ ) ;
1202+ const dateInput = datePicker . input ;
1203+ TestUtils . Simulate . click ( ReactDOM . findDOMNode ( dateInput ) ) ;
1204+
1205+ const arrow = TestUtils . scryRenderedDOMComponentsWithClass (
1206+ datePicker . calendar ,
1207+ "react-datepicker__triangle"
1208+ ) ;
1209+
1210+ expect ( arrow ) . to . be . empty ;
1211+ } ) ;
11821212} ) ;
You can’t perform that action at this time.
0 commit comments