Skip to content
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

Fix #5970: Calendar hideOnRangeSelection #5971

Merged
merged 1 commit into from
Feb 15, 2024
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
8 changes: 4 additions & 4 deletions components/doc/calendar/rangedoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function RangeDoc(props) {

const code = {
basic: `
<Calendar value={dates} onChange={(e) => setDates(e.value)} selectionMode="range" readOnlyInput />
<Calendar value={dates} onChange={(e) => setDates(e.value)} selectionMode="range" readOnlyInput hideOnRangeSelection />
`,
javascript: `
import React, { useState } from "react";
Expand All @@ -19,7 +19,7 @@ export default function RangeDemo() {
return (
<div className="card flex justify-content-center">
<Calendar value={dates} onChange={(e) => setDates(e.value)} selectionMode="range" readOnlyInput />
<Calendar value={dates} onChange={(e) => setDates(e.value)} selectionMode="range" readOnlyInput hideOnRangeSelection />
</div>
)
}
Expand All @@ -34,7 +34,7 @@ export default function RangeDemo() {
return (
<div className="card flex justify-content-center">
<Calendar value={dates} onChange={(e) => setDates(e.value)} selectionMode="range" readOnlyInput />
<Calendar value={dates} onChange={(e) => setDates(e.value)} selectionMode="range" readOnlyInput hideOnRangeSelection />
</div>
)
Expand All @@ -50,7 +50,7 @@ export default function RangeDemo() {
</p>
</DocSectionText>
<div className="card flex justify-content-center">
<Calendar value={dates} onChange={(e) => setDates(e.value)} selectionMode="range" readOnlyInput />
<Calendar value={dates} onChange={(e) => setDates(e.value)} selectionMode="range" readOnlyInput hideOnRangeSelection />
</div>
<DocSectionCode code={code} />
</>
Expand Down
6 changes: 6 additions & 0 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1630,6 +1630,12 @@ export const Calendar = React.memo(

selectedValues = [startDate, endDate];
updateModel(event, selectedValues);

if (props.hideOnRangeSelection && endDate !== null) {
setTimeout(() => {
setOverlayVisibleState(false);
}, 150);
}
} else {
selectedValues = [date, null];
updateModel(event, selectedValues);
Expand Down
1 change: 1 addition & 0 deletions components/lib/calendar/CalendarBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ export const CalendarBase = ComponentBase.extend({
formatDateTime: null,
headerTemplate: null,
hideOnDateTimeSelect: false,
hideOnRangeSelection: false,
hourFormat: '24',
icon: null,
iconPos: 'right',
Expand Down
4 changes: 4 additions & 0 deletions components/lib/calendar/calendar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ interface CalendarBaseProps {
* @defaultValue false
*/
hideOnDateTimeSelect?: boolean | undefined;
/**
* Whether to hide the overlay on date selection is completed when selectionMode is range.
*/
hideOnRangeSelection?: boolean | undefined;
/**
* Specifies 12 or 24 hour format.
* @defaultValue 24
Expand Down
Loading