Skip to content

Commit

Permalink
Fixed Modal announcing + Fixed Calendar closing behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-lin12 committed Nov 6, 2023
1 parent bd1bac9 commit 5ecd090
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
34 changes: 20 additions & 14 deletions frontend/src/components/MiniCal/MiniCal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,33 @@ const Icon = () => (
);

const MiniCal = () => {
const [isCalendarOpen, setIsCalendarOpen] = useState(false);
const { curDate, setCurDate } = useDate();
const [isExpanded, setExpanded] = useState('Collapsed');

const updateDate = (d: Date) => {
setCurDate(d);
};

const updateExpanded = (s: string) => {
setExpanded(s);
};

class CustomInput extends React.Component<any> {
render() {
return (
<button
className={styles.customInput}
onClick={this.props.onClick}
aria-expanded={isCalendarOpen}
>
<span className={styles.primary}>
{isToday(curDate) ? 'Today ' : ' '}
{isTomorrow(curDate) ? 'Tomorrow ' : ' '}
<>
<span aria-live="polite" className={styles.modal_state}>
Modal is{isExpanded}
</span>
<span className={styles.space} /> <Icon />
<span className={styles.space} /> {this.props.value}
</button>
<button className={styles.customInput} onClick={this.props.onClick}>
<span className={styles.primary}>
{isToday(curDate) ? 'Today ' : ' '}
{isTomorrow(curDate) ? 'Tomorrow ' : ' '}
</span>
<span className={styles.space} /> <Icon />
<span className={styles.space} /> {this.props.value}
</button>
</>
);
}
}
Expand Down Expand Up @@ -92,8 +98,8 @@ const MiniCal = () => {
closeOnScroll={true}
dateFormat="MMM dd, yyyy"
showPopperArrow={false}
onCalendarClose={() => setIsCalendarOpen(false)}
onCalendarOpen={() => setIsCalendarOpen(true)}
onCalendarOpen={() => updateExpanded('Expanded')}
onCalendarClose={() => updateExpanded('Collapsed')}
customInput={<CustomInput />}
highlightDates={[{ 'custom--today': [new Date()] }]}
renderCustomHeader={({
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/MiniCal/datepicker_override.css
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
.react-datepicker__quarter-text.react-datepicker__quarter--in-range:hover {
background-color: #000000;
}

.react-datepicker__month--selected:hover,
.react-datepicker__month--in-selecting-range:hover,
.react-datepicker__month--in-range:hover,
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/components/MiniCal/minical.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,12 @@
.space {
width: 0.5em;
}

.modal_state {
top: 0;
left: -2px;
width: 1px;
height: 1px;
position: absolute;
overflow: hidden;
}

0 comments on commit 5ecd090

Please sign in to comment.