Fix props validation for Breadcrumb#4666
Conversation
b450575 to
61224e6
Compare
| private _validateProps(props: IBreadcrumbProps): void { | ||
| const { items, overflowIndex } = props; | ||
| if (overflowIndex! < 0 || overflowIndex! > items.length - 1) { | ||
| if (overflowIndex! < 0 || overflowIndex! > items.length) { |
There was a problem hiding this comment.
This fixes the issue when items is of 0 length. However, if items is of length N and overflowIndex is also N, I think this new change will now consider that a valid scenario when it isn't. I wonder if instead overflowIndex should only be compared against items.length when items.length is > 0 (leaving the original items.length - 1 change in.)
There was a problem hiding this comment.
(I guess some expect error test cases would be useful here too.)
JasonGore
left a comment
There was a problem hiding this comment.
Requesting feedback regarding potential bug introduced in validate function
61224e6 to
45c7a49
Compare
| if (overflowIndex! < 0 || overflowIndex! > items.length - 1) { | ||
| const { maxDisplayedItems, overflowIndex, items } = props; | ||
| if (overflowIndex! < 0 || | ||
| maxDisplayedItems! > 1 && overflowIndex! > maxDisplayedItems! - 1 || |
There was a problem hiding this comment.
Should overflowIndex be compared against maxDisplayedItems when maxDisplayedItems is 1?
There was a problem hiding this comment.
I think this is enough sanity checking for the moment. The component doesn't actually break if you specify values out-of-bounds.
* master: (42 commits) Applying package updates. ProgressIndicator: Finish conversion to mergeStyles (microsoft#4595) Fix props validation for Breadcrumb (microsoft#4666) No unused vars part of ts (microsoft#4670) Picker/Autofill: fixes several minor bugs. (microsoft#4569) Fix Calendar component PREV/NEXT month, year, and "Go to today" handlers firing twice (microsoft#4662) Applying package updates. Merge styles order (microsoft#4664) Fabric component: revert class change and make it backwards compatible (microsoft#4671) Addressing Issue microsoft#3707 - OverflowSet: Add the ability to set aria-label (microsoft#4667) Fix input type for Tile ARIA label prop (microsoft#4668) Fix theme slots for DetailsList header colors (microsoft#4658) Applying package updates. Jolore/calendar updates (microsoft#4643) Remove wordWrap setting. (microsoft#4657) Pivot: convert to mergeStyles - part 1 (microsoft#4656) Use the `data-is-scrollable` attribute on the correct ScrollablePane div (microsoft#4602) Applying package updates. Remove unused iconClassName prop from Nav.types (microsoft#4634) Jest snapshots: classes in animations should autoexpand. (microsoft#4647) ...
* master: (34 commits) Applying package updates. ProgressIndicator: Finish conversion to mergeStyles (microsoft#4595) Fix props validation for Breadcrumb (microsoft#4666) No unused vars part of ts (microsoft#4670) Picker/Autofill: fixes several minor bugs. (microsoft#4569) Fix Calendar component PREV/NEXT month, year, and "Go to today" handlers firing twice (microsoft#4662) Applying package updates. Merge styles order (microsoft#4664) Fabric component: revert class change and make it backwards compatible (microsoft#4671) Addressing Issue microsoft#3707 - OverflowSet: Add the ability to set aria-label (microsoft#4667) Fix input type for Tile ARIA label prop (microsoft#4668) Fix theme slots for DetailsList header colors (microsoft#4658) Applying package updates. Jolore/calendar updates (microsoft#4643) Remove wordWrap setting. (microsoft#4657) Pivot: convert to mergeStyles - part 1 (microsoft#4656) Use the `data-is-scrollable` attribute on the correct ScrollablePane div (microsoft#4602) Applying package updates. Remove unused iconClassName prop from Nav.types (microsoft#4634) Jest snapshots: classes in animations should autoexpand. (microsoft#4647) ...
Overview
This change is to address bug #4663:
itemsis[]).items.lengthis0, and also added validation againstmaxDisplayedItems, since that impacts overflow behavior, too.