Skip to content

Fix Issue 5864 - Enable to Clear Date #5902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/shared/components/Settings/Profile/Work/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,10 @@ export default class Work extends ConsentComponent {
}

onUpdateDate(date, timePeriod) {
if (date) {
const { newWork: oldWork } = this.state;
const newWork = { ...oldWork };
newWork[timePeriod] = date;
this.setState({ newWork, isSubmit: false });
}
const { newWork: oldWork } = this.state;
const newWork = { ...oldWork };
newWork[timePeriod] = date;
this.setState({ newWork, isSubmit: false });
}

/**
Expand Down Expand Up @@ -491,11 +489,13 @@ export default class Work extends ConsentComponent {
<div styleName="field col-2">
<DatePicker
readOnly
showClearDate
numberOfMonths={1}
isOutsideRange={moment().subtract(1, 'd')}
date={newWork.timePeriodFrom}
id="date-from1"
onDateChange={date => this.onUpdateDate(date, 'timePeriodFrom')}
onClearDate={date => this.onUpdateDate('', 'timePeriodFrom')}
placeholder="dd/mm/yyyy"
/>
{
Expand All @@ -518,12 +518,14 @@ export default class Work extends ConsentComponent {
<div styleName="field col-2">
<DatePicker
readOnly
showClearDate
disabled={endDateDisabled}
numberOfMonths={1}
isOutsideRange={moment().subtract(1, 'd')}
date={newWork.timePeriodTo}
id="date-to1"
onDateChange={date => this.onUpdateDate(date, 'timePeriodTo')}
onClearDate={date => this.onUpdateDate('', 'timePeriodTo')}
placeholder="dd/mm/yyyy"
/>
{
Expand Down Expand Up @@ -642,11 +644,13 @@ export default class Work extends ConsentComponent {
</label>
<DatePicker
readOnly
showClearDate
numberOfMonths={1}
isOutsideRange={moment().subtract(1, 'd')}
date={newWork.timePeriodFrom}
id="date-from2"
onDateChange={date => this.onUpdateDate(date, 'timePeriodFrom')}
onClearDate={date => this.onUpdateDate('', 'timePeriodFrom')}
placeholder="dd/mm/yyyy"
/>
{
Expand All @@ -665,12 +669,14 @@ export default class Work extends ConsentComponent {
</label>
<DatePicker
readOnly
showClearDate
disabled={endDateDisabled}
numberOfMonths={1}
isOutsideRange={moment().subtract(1, 'd')}
date={newWork.timePeriodTo}
id="date-to2"
onDateChange={date => this.onUpdateDate(date, 'timePeriodTo')}
onClearDate={date => this.onUpdateDate('', 'timePeriodTo')}
placeholder="dd/mm/yyyy"
/>
{
Expand Down
14 changes: 14 additions & 0 deletions src/shared/components/Settings/Profile/Work/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,20 @@ label {
display: none;
}
}

:global {
.SingleDatePickerInput_clearDate {
height: 35px;
width: 35px;
display: flex;
align-items: center;
top: calc(50% - 5px);
}

.SingleDatePickerInput__showClearDate {
padding-right: 0;
}
}
}

.button-container {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import './_fix_SingleDatePicker.css';

const propTypes = {
autoFocus: PropTypes.bool,
showClearDate: PropTypes.bool,
allowFutureYear: PropTypes.bool,

...omit({}, [
Expand All @@ -25,6 +26,7 @@ const propTypes = {
const defaultProps = {
autoFocus: false,
allowFutureYear: false,
showClearDate: false,
};

class DatePicker extends React.Component {
Expand Down Expand Up @@ -53,7 +55,7 @@ class DatePicker extends React.Component {
render() {
const { focused, allowFutureYear } = this.state;
const {
id, date, onDateChange, isOutsideRange,
id, date, onDateChange, isOutsideRange, showClearDate,
} = this.props;

const props = omit(this.props, [
Expand All @@ -75,6 +77,7 @@ class DatePicker extends React.Component {
focused={focused}
onDateChange={onDateChange}
onFocusChange={this.onFocusChange}
showClearDate={showClearDate}
renderMonthElement={({ month, onMonthSelect, onYearSelect }) => (
<div style={{ display: 'flex', justifyContent: 'center' }}>
<div>
Expand Down