Skip to content

Commit 62b23bd

Browse files
committed
chore(Datepicker): getElementSelectorToFocus function description
1 parent 46a3254 commit 62b23bd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/react-core/src/components/DatePicker/DatePicker.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,12 @@ const DatePickerBase = (
236236
);
237237
const focusSelectorForUnselectedDate = createFocusSelectorString(calendarMonthStyles.modifiers.current);
238238

239-
const getElementToFocus = () => {
239+
/**
240+
* Returns a CSS selector for a date button element which will receive initial focus after opening calendar popover.
241+
* In case of a range picker it returns the end date, if it is selected, start date otherwise.
242+
* In case of a normal datepicker it returns the selected date, if present, today otherwise.
243+
*/
244+
const getElementSelectorToFocus = () => {
240245
if (isValidDate(valueDate) && isValidDate(rangeStart)) {
241246
return focusSelectorForSelectedEndRangeDate;
242247
}
@@ -249,7 +254,7 @@ const DatePickerBase = (
249254
return (
250255
<div className={css(styles.datePicker, className)} ref={datePickerWrapperRef} style={style} {...props}>
251256
<Popover
252-
elementToFocus={getElementToFocus()}
257+
elementToFocus={getElementSelectorToFocus()}
253258
position="bottom"
254259
bodyContent={
255260
<CalendarMonth

0 commit comments

Comments
 (0)