File tree Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Expand file tree Collapse file tree 2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ const defaultProps = {
3737 focused : false ,
3838 disabled : false ,
3939 required : false ,
40- readOnly : false ,
40+ readOnly : null ,
4141 showCaret : false ,
4242
4343 onChange ( ) { } ,
@@ -172,7 +172,7 @@ export default class DateInput extends React.Component {
172172 placeholder = { placeholder }
173173 autoComplete = "off"
174174 disabled = { disabled }
175- readOnly = { readOnly || isTouch }
175+ readOnly = { typeof readOnly === 'boolean' ? readOnly : isTouch }
176176 required = { required }
177177 aria-describedby = { screenReaderMessage && screenReaderMessageId }
178178 />
Original file line number Diff line number Diff line change @@ -273,18 +273,18 @@ describe('DateInput', () => {
273273 expect ( wrapper . state ( ) ) . to . contain . keys ( { isTouchDevice : false } ) ;
274274 } ) ;
275275
276- it ( 'sets readOnly when a touch device and props.readOnly === true ' , ( ) => {
277- const wrapper = shallow ( < DateInput id = "date" readOnly /> ) ;
276+ it ( 'sets readOnly to true when no value was provided on a touch device ' , ( ) => {
277+ const wrapper = shallow ( < DateInput id = "date" /> ) ;
278278 wrapper . setState ( { isTouchDevice : true } ) ;
279279 wrapper . update ( ) ;
280280 expect ( ! ! wrapper . find ( 'input' ) . prop ( 'readOnly' ) ) . to . equal ( true ) ;
281281 } ) ;
282282
283- it ( 'sets readOnly when a touch device and props.readOnly === false ' , ( ) => {
283+ it ( 'sets readOnly to provided value on a touch device ' , ( ) => {
284284 const wrapper = shallow ( < DateInput id = "date" readOnly = { false } /> ) ;
285285 wrapper . setState ( { isTouchDevice : true } ) ;
286286 wrapper . update ( ) ;
287- expect ( ! ! wrapper . find ( 'input' ) . prop ( 'readOnly' ) ) . to . equal ( true ) ;
287+ expect ( ! ! wrapper . find ( 'input' ) . prop ( 'readOnly' ) ) . to . equal ( false ) ;
288288 } ) ;
289289
290290 describe ( 'focus/isFocused' , ( ) => {
You can’t perform that action at this time.
0 commit comments