Skip to content

Conversation

@foxbunny
Copy link
Collaborator

No description provided.

@foxbunny foxbunny force-pushed the date-picker-date-filter branch from 39504bd to a648d88 Compare May 29, 2025 11:02
@foxbunny foxbunny requested a review from ThiefMaster May 29, 2025 11:05
@foxbunny foxbunny force-pushed the date-picker-date-filter branch from a648d88 to fc57274 Compare May 29, 2025 11:08
@ThiefMaster
Copy link
Member

While disabling works (I tested it in room booking), it doesn't actually display the disabled dates as inactive (w/ your example code that disables weekends).

@foxbunny
Copy link
Collaborator Author

While disabling works (I tested it in room booking), it doesn't actually display the disabled dates as inactive (w/ your example code that disables weekends).

Sorry, missed your comment. I'll check and adjust.

@foxbunny
Copy link
Collaborator Author

@ThiefMaster Can you tell me more about what you tried? I've manually overridden the filter prop like so:

diff --git a/indico/web/client/js/react/components/DatePicker.jsx b/indico/web/client/js/react/components/DatePicker.jsx
index 836378c241..dd4e95b111 100644
--- a/indico/web/client/js/react/components/DatePicker.jsx
+++ b/indico/web/client/js/react/components/DatePicker.jsx
@@ -37,6 +37,10 @@ export default function DatePicker({

   const formattedValue = formatDate(format, fromISOLocalDate(value));

+  filter = (d, meta) => {
+    return !meta.weekInfo.weekend.includes(d.getDay() || 7);
+  };
+
   return (
     <ind-date-picker
       min={fromISOLocalDate(min)?.toDateString()}

With this patch, I get the intended result:

image

@ThiefMaster
Copy link
Member

This is what I Tested with (in room booking)

diff --git a/indico/modules/rb/client/js/components/BookingBootstrapForm.jsx b/indico/modules/rb/client/js/components/BookingBootstrapForm.jsx
index da5f9ca2fe..e2d3ff162a 100644
--- a/indico/modules/rb/client/js/components/BookingBootstrapForm.jsx
+++ b/indico/modules/rb/client/js/components/BookingBootstrapForm.jsx
@@ -381,6 +381,7 @@ class BookingBootstrapForm extends React.Component {
           <Form.Group inline>
             <DateRangePicker
               min={getBookingRangeMinDate(isAdminOverrideEnabled, bookingGracePeriod)}
+              filter={(d, meta) => !meta.weekInfo.weekend.includes(d.getDay() || 7)}
               value={{startDate: serializeDate(startDate), endDate: serializeDate(endDate)}}
               onChange={({startDate: sd, endDate: ed}) =>
                 this.updateDates(toMoment(sd), toMoment(ed))
@@ -392,6 +393,7 @@ class BookingBootstrapForm extends React.Component {
           <Form.Group inline>
             <DatePicker
               min={getBookingRangeMinDate(isAdminOverrideEnabled, bookingGracePeriod)}
+              filter={(d, meta) => !meta.weekInfo.weekend.includes(d.getDay() || 7)}
               value={serializeDate(startDate)}
               invalidValue={null}
               onChange={date => this.updateDates(toMoment(date), null)}

@foxbunny foxbunny force-pushed the date-picker-date-filter branch from fc57274 to 2aa9cae Compare June 20, 2025 03:23
@foxbunny
Copy link
Collaborator Author

Turns out even I forgot the subtle nuances of disabling dates. 😂 Had to use aria-disabled instead of disabled cause the buttons still need to be reachable by keyboard. Anyway, this should fix it across the board now.

@ThiefMaster ThiefMaster force-pushed the date-picker-date-filter branch from 2aa9cae to 2ae37eb Compare June 20, 2025 11:59
@ThiefMaster ThiefMaster merged commit 8ae6779 into indico:master Jun 20, 2025
11 checks passed
@ThiefMaster ThiefMaster added this to the v3.3 milestone Jun 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants