@instructure/ui-drilldown 9.1.1-snapshot-9 → 9.1.1-snapshot-14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,9 +3,12 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## [9.1.1-snapshot-9](https://github.com/instructure/instructure-ui/compare/v9.1.0...v9.1.1-snapshot-9) (2024-07-05)
6
+ ## [9.1.1-snapshot-14](https://github.com/instructure/instructure-ui/compare/v9.1.0...v9.1.1-snapshot-14) (2024-07-05)
7
7
 
8
- **Note:** Version bump only for package @instructure/ui-drilldown
8
+
9
+ ### Bug Fixes
10
+
11
+ * **ui-drilldown:** index drilldown options to always preserve the correct order ([3159d06](https://github.com/instructure/instructure-ui/commit/3159d06eb7aad8573c2227f379af1e716b09e391))
9
12
 
10
13
 
11
14
 
@@ -396,7 +396,10 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
396
396
  };
397
397
  }
398
398
  get activeOptionIds() {
399
- return Object.keys(this._activeOptionsMap);
399
+ const orderedKeys = Object.keys(this._activeOptionsMap).sort((a, b) => {
400
+ return this._activeOptionsMap[a].index - this._activeOptionsMap[b].index;
401
+ });
402
+ return orderedKeys;
400
403
  }
401
404
  get activeOptions() {
402
405
  return Object.values(this._activeOptionsMap);
@@ -831,11 +834,13 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
831
834
  };
832
835
  }
833
836
 
834
- // track as valid active option if not the title
835
- if (id !== this._headerTitleId) {
837
+ // track as valid active option if not the title and the map doesn't already contain the id
838
+ if (id !== this._headerTitleId && !this._activeOptionsMap[id]) {
839
+ // store index to know the order of ids later; js objects doesn't preserve order
836
840
  this._activeOptionsMap[id] = {
837
841
  ...option,
838
- ...optionData
842
+ ...optionData,
843
+ index: Object.keys(this._activeOptionsMap).length + 1
839
844
  };
840
845
  }
841
846
  const customRole = role !== DrilldownOption.defaultProps.role ? role : void 0;
@@ -406,7 +406,10 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
406
406
  };
407
407
  }
408
408
  get activeOptionIds() {
409
- return Object.keys(this._activeOptionsMap);
409
+ const orderedKeys = Object.keys(this._activeOptionsMap).sort((a, b) => {
410
+ return this._activeOptionsMap[a].index - this._activeOptionsMap[b].index;
411
+ });
412
+ return orderedKeys;
410
413
  }
411
414
  get activeOptions() {
412
415
  return Object.values(this._activeOptionsMap);
@@ -841,11 +844,13 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
841
844
  };
842
845
  }
843
846
 
844
- // track as valid active option if not the title
845
- if (id !== this._headerTitleId) {
847
+ // track as valid active option if not the title and the map doesn't already contain the id
848
+ if (id !== this._headerTitleId && !this._activeOptionsMap[id]) {
849
+ // store index to know the order of ids later; js objects doesn't preserve order
846
850
  this._activeOptionsMap[id] = {
847
851
  ...option,
848
- ...optionData
852
+ ...optionData,
853
+ index: Object.keys(this._activeOptionsMap).length + 1
849
854
  };
850
855
  }
851
856
  const customRole = role !== _DrilldownOption.DrilldownOption.defaultProps.role ? role : void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-drilldown",
3
- "version": "9.1.1-snapshot-9",
3
+ "version": "9.1.1-snapshot-14",
4
4
  "description": "A drilldown menu component",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,28 +24,28 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.24.5",
27
- "@instructure/console": "9.1.1-snapshot-9",
28
- "@instructure/emotion": "9.1.1-snapshot-9",
29
- "@instructure/shared-types": "9.1.1-snapshot-9",
30
- "@instructure/ui-dom-utils": "9.1.1-snapshot-9",
31
- "@instructure/ui-icons": "9.1.1-snapshot-9",
32
- "@instructure/ui-options": "9.1.1-snapshot-9",
33
- "@instructure/ui-popover": "9.1.1-snapshot-9",
34
- "@instructure/ui-position": "9.1.1-snapshot-9",
35
- "@instructure/ui-prop-types": "9.1.1-snapshot-9",
36
- "@instructure/ui-react-utils": "9.1.1-snapshot-9",
37
- "@instructure/ui-selectable": "9.1.1-snapshot-9",
38
- "@instructure/ui-testable": "9.1.1-snapshot-9",
39
- "@instructure/ui-utils": "9.1.1-snapshot-9",
40
- "@instructure/ui-view": "9.1.1-snapshot-9",
27
+ "@instructure/console": "9.1.1-snapshot-14",
28
+ "@instructure/emotion": "9.1.1-snapshot-14",
29
+ "@instructure/shared-types": "9.1.1-snapshot-14",
30
+ "@instructure/ui-dom-utils": "9.1.1-snapshot-14",
31
+ "@instructure/ui-icons": "9.1.1-snapshot-14",
32
+ "@instructure/ui-options": "9.1.1-snapshot-14",
33
+ "@instructure/ui-popover": "9.1.1-snapshot-14",
34
+ "@instructure/ui-position": "9.1.1-snapshot-14",
35
+ "@instructure/ui-prop-types": "9.1.1-snapshot-14",
36
+ "@instructure/ui-react-utils": "9.1.1-snapshot-14",
37
+ "@instructure/ui-selectable": "9.1.1-snapshot-14",
38
+ "@instructure/ui-testable": "9.1.1-snapshot-14",
39
+ "@instructure/ui-utils": "9.1.1-snapshot-14",
40
+ "@instructure/ui-view": "9.1.1-snapshot-14",
41
41
  "prop-types": "^15.8.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@instructure/ui-babel-preset": "9.1.1-snapshot-9",
45
- "@instructure/ui-color-utils": "9.1.1-snapshot-9",
46
- "@instructure/ui-test-locator": "9.1.1-snapshot-9",
47
- "@instructure/ui-test-utils": "9.1.1-snapshot-9",
48
- "@instructure/ui-themes": "9.1.1-snapshot-9"
44
+ "@instructure/ui-babel-preset": "9.1.1-snapshot-14",
45
+ "@instructure/ui-color-utils": "9.1.1-snapshot-14",
46
+ "@instructure/ui-test-locator": "9.1.1-snapshot-14",
47
+ "@instructure/ui-test-utils": "9.1.1-snapshot-14",
48
+ "@instructure/ui-themes": "9.1.1-snapshot-14"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "react": ">=16.8 <=18"
@@ -85,7 +85,7 @@ type OptionData = {
85
85
 
86
86
  // Contains the Option ComponentElement and the extra data we need track on it,
87
87
  // but don't want to expose as props
88
- type MappedOption = OptionChild & OptionData
88
+ type MappedOption = OptionChild & OptionData & { index: number }
89
89
 
90
90
  // Contains the props object of the Page
91
91
  // with the `children` transformed into an array
@@ -248,7 +248,10 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
248
248
  }
249
249
 
250
250
  get activeOptionIds() {
251
- return Object.keys(this._activeOptionsMap)
251
+ const orderedKeys = Object.keys(this._activeOptionsMap).sort((a, b) => {
252
+ return this._activeOptionsMap[a].index - this._activeOptionsMap[b].index
253
+ })
254
+ return orderedKeys
252
255
  }
253
256
 
254
257
  get activeOptions() {
@@ -1076,9 +1079,14 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
1076
1079
  optionProps = { ...optionProps, ...getDisabledOptionProps() }
1077
1080
  }
1078
1081
 
1079
- // track as valid active option if not the title
1080
- if (id !== this._headerTitleId) {
1081
- this._activeOptionsMap[id] = { ...option, ...optionData }
1082
+ // track as valid active option if not the title and the map doesn't already contain the id
1083
+ if (id !== this._headerTitleId && !this._activeOptionsMap[id]) {
1084
+ // store index to know the order of ids later; js objects doesn't preserve order
1085
+ this._activeOptionsMap[id] = {
1086
+ ...option,
1087
+ ...optionData,
1088
+ index: Object.keys(this._activeOptionsMap).length + 1
1089
+ }
1082
1090
  }
1083
1091
 
1084
1092
  const customRole =