Skip to content

Commit 7be55cd

Browse files
dakahntay1orjoneskodiakhq[bot]
authored
fix(DatePicker): remove decorative svg as a click target (#10283)
* fix(DatePicker): remove decorative svg as a click target * test(datepicker): remove usages of removed openCalendar prop, mirror style changes * fix(DatePicker): add deprecation warnings for unneeded props * test(DatePicker): update snapshot tests * fix(datepicker): no longer call deprecated openCalendar input prop Co-authored-by: Taylor Jones <taylor.jones826@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 334821f commit 7be55cd

File tree

6 files changed

+15
-34
lines changed

6 files changed

+15
-34
lines changed

packages/components/src/components/date-picker/_date-picker.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@
134134
// vertically center icon within parent container on IE11
135135
top: 50%;
136136
right: 1rem;
137-
cursor: pointer;
138137
fill: $icon-primary;
138+
pointer-events: none;
139139
transform: translateY(-50%);
140140
}
141141

packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,9 +2502,7 @@ Map {
25022502
"hideLabel": Object {
25032503
"type": "bool",
25042504
},
2505-
"iconDescription": Object {
2506-
"type": "string",
2507-
},
2505+
"iconDescription": [Function],
25082506
"id": Object {
25092507
"isRequired": true,
25102508
"type": "string",
@@ -2525,9 +2523,7 @@ Map {
25252523
"onClick": Object {
25262524
"type": "func",
25272525
},
2528-
"openCalendar": Object {
2529-
"type": "func",
2530-
},
2526+
"openCalendar": [Function],
25312527
"pattern": [Function],
25322528
"placeholder": Object {
25332529
"type": "string",

packages/react/src/components/DatePicker/DatePicker-test.js

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -354,21 +354,6 @@ describe('DatePicker', () => {
354354
});
355355
});
356356

357-
describe('DatePickerInput', () => {
358-
it('should call `openCalendar` on calendar icon click', () => {
359-
const mockOpenCalendar = jest.fn();
360-
const wrapper = mount(
361-
<DatePickerInput
362-
labelText="Date Picker label"
363-
id="input-from"
364-
openCalendar={mockOpenCalendar}
365-
/>
366-
);
367-
wrapper.find('svg').simulate('click');
368-
expect(mockOpenCalendar).toHaveBeenCalled();
369-
});
370-
});
371-
372357
describe('DatePickerSkeleton', () => {
373358
describe('Renders as expected', () => {
374359
const wrapper = shallow(<DatePickerSkeleton range />);

packages/react/src/components/DatePicker/DatePicker.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -529,12 +529,6 @@ export default class DatePicker extends Component {
529529
</svg>`;
530530
}
531531

532-
openCalendar = () => {
533-
if (this.cal) {
534-
this.cal.open();
535-
}
536-
};
537-
538532
updateClassNames = (calendar) => {
539533
const calendarContainer = calendar.calendarContainer;
540534
const daysContainer = calendar.days;
@@ -660,7 +654,6 @@ export default class DatePicker extends Component {
660654
return React.cloneElement(child, {
661655
datePickerType,
662656
ref: this.assignInputFieldRef,
663-
openCalendar: this.openCalendar,
664657
});
665658
}
666659
if (
@@ -671,7 +664,6 @@ export default class DatePicker extends Component {
671664
return React.cloneElement(child, {
672665
datePickerType,
673666
ref: this.assignToInputFieldRef,
674-
openCalendar: this.openCalendar,
675667
});
676668
}
677669
if (index === 0) {

packages/react/src/components/DatePickerInput/DatePickerInput.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import PropTypes from 'prop-types';
99
import React, { Component } from 'react';
10+
import deprecate from '../../prop-types/deprecate';
1011
import classNames from 'classnames';
1112
import { settings } from 'carbon-components';
1213
import {
@@ -46,7 +47,10 @@ export default class DatePickerInput extends Component {
4647
/**
4748
* The description of the calendar icon.
4849
*/
49-
iconDescription: PropTypes.string,
50+
iconDescription: deprecate(
51+
PropTypes.string,
52+
`\nThe prop \`iconDescriptionInput\` for DatePickerInput has been deprecated and is no longer used`
53+
),
5054

5155
/**
5256
* Specify an id that uniquely identifies the `<input>`
@@ -83,7 +87,10 @@ export default class DatePickerInput extends Component {
8387
/**
8488
* Provide a function to be called when the input field is clicked
8589
*/
86-
openCalendar: PropTypes.func,
90+
openCalendar: deprecate(
91+
PropTypes.func,
92+
`\nThe prop \`openCalendar\` for DatePickerInput has been deprecated and is no longer used`
93+
),
8794

8895
/**
8996
* Provide a regular expression that the input value must match
@@ -220,7 +227,8 @@ export default class DatePickerInput extends Component {
220227
className={`${prefix}--date-picker__icon`}
221228
aria-label={iconDescription}
222229
onClick={openCalendar}
223-
role="img">
230+
role="img"
231+
aria-hidden="true">
224232
{iconDescription && <title>{iconDescription}</title>}
225233
</Calendar16>
226234
);

packages/styles/scss/components/date-picker/_date-picker.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,8 @@
141141
// vertically center icon within parent container on IE11
142142
top: 50%;
143143
right: 1rem;
144-
cursor: pointer;
145144
fill: $icon-primary;
145+
pointer-events: none;
146146
transform: translateY(-50%);
147147
}
148148

0 commit comments

Comments
 (0)