Skip to content

Commit

Permalink
STSMACOM-859: Add the endDateInputRef prop to DateRangeFilter to acce…
Browse files Browse the repository at this point in the history
…ss the end date element. (#1527)
  • Loading branch information
Dmytro-Melnyshyn authored Oct 18, 2024
1 parent aa0f86a commit 53ad926
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* Avoid deprecated `defaultProps` for functional components. Refs STSMACOM-835.
* Upgrade `notes` to `v4.0`. Refs STSMACOM-861.
* Improve confirmation modal footer for `ControlledVocab` component. Refs STSMACOM-863.
* Add the `endDateInputRef` prop to `DateRangeFilter` to access the end date element. Refs STSMACOM-859.

## [9.1.3](https://github.com/folio-org/stripes-smart-components/tree/v9.1.3) (2024-05-06)
[Full Changelog](https://github.com/folio-org/stripes-smart-components/compare/v9.1.2...v9.1.3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ const TheComponent = ({
// accessible label for disambiguating this end input from others.
endLabel,
hideCalendarButton = false,
endDateInputRef,
}) => {
const [filterValue, setFilterValue] = React.useState({
...defaultFilterState,
Expand All @@ -105,6 +106,7 @@ const TheComponent = ({

const setFocusRef = useSetRef(focusRef);
const setFocusRefOnFocus = useSetRefOnFocus(focusRef);
const setEndDateInputRef = useSetRef(endDateInputRef);

const { errors, selectedValues: selectedValuesState } = filterValue;
const { startDate, endDate } = selectedValuesState;
Expand Down Expand Up @@ -217,7 +219,10 @@ const TheComponent = ({
onKeyDown={handleKeyDown}
placement={placement}
usePortal
inputRef={setFocusRef}
inputRef={element => {
setFocusRef(element);
setEndDateInputRef(element);
}}
aria-label={endLabel}
hideCalendarButton={hideCalendarButton}
/>
Expand Down Expand Up @@ -250,6 +255,7 @@ TheComponent.propTypes = {
}).isRequired,
startLabel: PropTypes.string,
requiredFields: PropTypes.arrayOf(PropTypes.oneOf([DATE_TYPES.START, DATE_TYPES.END])),
endDateInputRef: PropTypes.oneOfType([PropTypes.object, PropTypes.func]),
};

const DateRangeFilter = memo(TheComponent, arePropsEqual);
Expand Down

0 comments on commit 53ad926

Please sign in to comment.