Skip to content

Commit

Permalink
[pickers] Fix DateTimeRangePicker error when using format without t…
Browse files Browse the repository at this point in the history
…ime (@fxnoob) (#15341)

Co-authored-by: Hitesh S. <[email protected]>
Co-authored-by: Lukas Tyla <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent ead6cb7 commit dd0ea70
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { getSectionVisibleValue } from './useField.utils';
import { getSectionVisibleValue, parseSelectedSections } from './useField.utils';

const COMMON_PROPERTIES = {
startSeparator: '',
Expand Down Expand Up @@ -56,4 +56,10 @@ describe('useField utility functions', () => {
).to.equal('\u20681\u2069');
});
});

describe('parseSelectedSections', () => {
it('should return null when selectedSections is not available in sections', () => {
expect(parseSelectedSections('year', [])).to.equal(null);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,8 @@ export const parseSelectedSections = (
}

if (typeof selectedSections === 'string') {
return sections.findIndex((section) => section.type === selectedSections);
const index = sections.findIndex((section) => section.type === selectedSections);
return index === -1 ? null : index;
}

return selectedSections;
Expand Down

0 comments on commit dd0ea70

Please sign in to comment.