@instructure/ui-drilldown 10.19.1-snapshot-1 → 10.19.1-snapshot-3
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 +5 -2
- package/es/Drilldown/index.js +25 -8
- package/lib/Drilldown/index.js +25 -8
- package/package.json +21 -21
- package/src/Drilldown/index.tsx +20 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Drilldown/index.d.ts +1 -0
- package/types/Drilldown/index.d.ts.map +1 -1
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
|
-
## [10.19.1-snapshot-
|
|
6
|
+
## [10.19.1-snapshot-3](https://github.com/instructure/instructure-ui/compare/v10.19.0...v10.19.1-snapshot-3) (2025-06-05)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **ui-drilldown:** fix highlighting first drilldown option if it is in a group ([3cc159b](https://github.com/instructure/instructure-ui/commit/3cc159bb0b6591bfb10eeeb6558dd384b09649d6))
|
|
9
12
|
|
|
10
13
|
|
|
11
14
|
|
package/es/Drilldown/index.js
CHANGED
|
@@ -335,10 +335,10 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
335
335
|
onToggle = _this$props2.onToggle,
|
|
336
336
|
trigger = _this$props2.trigger;
|
|
337
337
|
if (trigger && shown && this.currentPage) {
|
|
338
|
-
var _this$
|
|
338
|
+
var _this$getFirstOption;
|
|
339
339
|
const actionLabel = callRenderProp(this.currentPage.renderActionLabel);
|
|
340
340
|
// Use action ID if exists, otherwise first non-action option's ID
|
|
341
|
-
const targetId = actionLabel ? this._headerActionId : (_this$
|
|
341
|
+
const targetId = actionLabel ? this._headerActionId : (_this$getFirstOption = this.getFirstOption()) === null || _this$getFirstOption === void 0 ? void 0 : _this$getFirstOption.props.id;
|
|
342
342
|
setTimeout(() => {
|
|
343
343
|
this.setState({
|
|
344
344
|
highlightedOptionId: targetId
|
|
@@ -356,6 +356,23 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
356
356
|
});
|
|
357
357
|
}
|
|
358
358
|
};
|
|
359
|
+
this.getFirstOption = () => {
|
|
360
|
+
var _this$currentPage;
|
|
361
|
+
const children = Children.toArray((_this$currentPage = this.currentPage) === null || _this$currentPage === void 0 ? void 0 : _this$currentPage.children);
|
|
362
|
+
const child = children[0];
|
|
363
|
+
if (!child) return void 0;
|
|
364
|
+
|
|
365
|
+
// If it's a regular option, return it
|
|
366
|
+
if (matchComponentTypes(child, [DrilldownOption])) {
|
|
367
|
+
return child;
|
|
368
|
+
}
|
|
369
|
+
// If it's a group, get its options
|
|
370
|
+
if (matchComponentTypes(child, [Drilldown.Group])) {
|
|
371
|
+
const groupOptions = Children.toArray(child.props.children);
|
|
372
|
+
return groupOptions[0];
|
|
373
|
+
}
|
|
374
|
+
return void 0;
|
|
375
|
+
};
|
|
359
376
|
this.state = {
|
|
360
377
|
isShowingPopover: props.trigger ? !!props.show : false,
|
|
361
378
|
activePageId: props.rootPageId,
|
|
@@ -464,14 +481,14 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
464
481
|
};
|
|
465
482
|
}
|
|
466
483
|
get currentPageAriaLabel() {
|
|
467
|
-
var _this$
|
|
484
|
+
var _this$currentPage2;
|
|
468
485
|
// return, if explicitly set
|
|
469
486
|
if (this.props['aria-labelledby']) {
|
|
470
487
|
return this.props['aria-labelledby'];
|
|
471
488
|
}
|
|
472
489
|
|
|
473
490
|
// if it has title, point to the title label content
|
|
474
|
-
if ((_this$
|
|
491
|
+
if ((_this$currentPage2 = this.currentPage) !== null && _this$currentPage2 !== void 0 && _this$currentPage2.renderTitle) {
|
|
475
492
|
return this._headerTitleLabelId;
|
|
476
493
|
}
|
|
477
494
|
|
|
@@ -782,7 +799,7 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
782
799
|
});
|
|
783
800
|
}
|
|
784
801
|
renderOption(option, getOptionProps, getDisabledOptionProps, groupProps) {
|
|
785
|
-
var _this$
|
|
802
|
+
var _this$currentPage3, _optionProps$renderBe, _optionProps$renderBe2, _optionProps$renderAf, _optionProps$renderAf2;
|
|
786
803
|
const styles = this.props.styles;
|
|
787
804
|
let isSelected = false;
|
|
788
805
|
const _option$props = option.props,
|
|
@@ -842,7 +859,7 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
842
859
|
};
|
|
843
860
|
const isOptionDisabled = id !== this._headerBackId && (
|
|
844
861
|
// Back nav is never disabled
|
|
845
|
-
this.props.disabled || ((_this$
|
|
862
|
+
this.props.disabled || ((_this$currentPage3 = this.currentPage) === null || _this$currentPage3 === void 0 ? void 0 : _this$currentPage3.disabled) || (groupProps === null || groupProps === void 0 ? void 0 : groupProps.disabled) || disabled);
|
|
846
863
|
|
|
847
864
|
// display option as disabled
|
|
848
865
|
if (isOptionDisabled) {
|
|
@@ -1184,11 +1201,11 @@ let Drilldown = (_dec = withDeterministicId(), _dec2 = withStyle(generateStyle,
|
|
|
1184
1201
|
offsetX: offsetX,
|
|
1185
1202
|
offsetY: offsetY,
|
|
1186
1203
|
defaultFocusElement: () => {
|
|
1187
|
-
var _this$
|
|
1204
|
+
var _this$getFirstOption2, _this$_popover2, _this$_popover2$_cont;
|
|
1188
1205
|
if (!this.currentPage) return null;
|
|
1189
1206
|
const actionLabel = callRenderProp(this.currentPage.renderActionLabel);
|
|
1190
1207
|
// Use action ID if exists, otherwise first non-action option's ID
|
|
1191
|
-
const targetId = actionLabel ? this._headerActionId : (_this$
|
|
1208
|
+
const targetId = actionLabel ? this._headerActionId : (_this$getFirstOption2 = this.getFirstOption()) === null || _this$getFirstOption2 === void 0 ? void 0 : _this$getFirstOption2.props.id;
|
|
1192
1209
|
if (!targetId) return null;
|
|
1193
1210
|
return (_this$_popover2 = this._popover) === null || _this$_popover2 === void 0 ? void 0 : (_this$_popover2$_cont = _this$_popover2._contentElement) === null || _this$_popover2$_cont === void 0 ? void 0 : _this$_popover2$_cont.querySelector(`#${CSS.escape(targetId)}`);
|
|
1194
1211
|
},
|
package/lib/Drilldown/index.js
CHANGED
|
@@ -344,10 +344,10 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
344
344
|
onToggle = _this$props2.onToggle,
|
|
345
345
|
trigger = _this$props2.trigger;
|
|
346
346
|
if (trigger && shown && this.currentPage) {
|
|
347
|
-
var _this$
|
|
347
|
+
var _this$getFirstOption;
|
|
348
348
|
const actionLabel = (0, _callRenderProp.callRenderProp)(this.currentPage.renderActionLabel);
|
|
349
349
|
// Use action ID if exists, otherwise first non-action option's ID
|
|
350
|
-
const targetId = actionLabel ? this._headerActionId : (_this$
|
|
350
|
+
const targetId = actionLabel ? this._headerActionId : (_this$getFirstOption = this.getFirstOption()) === null || _this$getFirstOption === void 0 ? void 0 : _this$getFirstOption.props.id;
|
|
351
351
|
setTimeout(() => {
|
|
352
352
|
this.setState({
|
|
353
353
|
highlightedOptionId: targetId
|
|
@@ -365,6 +365,23 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
365
365
|
});
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
|
+
this.getFirstOption = () => {
|
|
369
|
+
var _this$currentPage;
|
|
370
|
+
const children = _react.Children.toArray((_this$currentPage = this.currentPage) === null || _this$currentPage === void 0 ? void 0 : _this$currentPage.children);
|
|
371
|
+
const child = children[0];
|
|
372
|
+
if (!child) return void 0;
|
|
373
|
+
|
|
374
|
+
// If it's a regular option, return it
|
|
375
|
+
if ((0, _matchComponentTypes.matchComponentTypes)(child, [_DrilldownOption.DrilldownOption])) {
|
|
376
|
+
return child;
|
|
377
|
+
}
|
|
378
|
+
// If it's a group, get its options
|
|
379
|
+
if ((0, _matchComponentTypes.matchComponentTypes)(child, [Drilldown.Group])) {
|
|
380
|
+
const groupOptions = _react.Children.toArray(child.props.children);
|
|
381
|
+
return groupOptions[0];
|
|
382
|
+
}
|
|
383
|
+
return void 0;
|
|
384
|
+
};
|
|
368
385
|
this.state = {
|
|
369
386
|
isShowingPopover: props.trigger ? !!props.show : false,
|
|
370
387
|
activePageId: props.rootPageId,
|
|
@@ -473,14 +490,14 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
473
490
|
};
|
|
474
491
|
}
|
|
475
492
|
get currentPageAriaLabel() {
|
|
476
|
-
var _this$
|
|
493
|
+
var _this$currentPage2;
|
|
477
494
|
// return, if explicitly set
|
|
478
495
|
if (this.props['aria-labelledby']) {
|
|
479
496
|
return this.props['aria-labelledby'];
|
|
480
497
|
}
|
|
481
498
|
|
|
482
499
|
// if it has title, point to the title label content
|
|
483
|
-
if ((_this$
|
|
500
|
+
if ((_this$currentPage2 = this.currentPage) !== null && _this$currentPage2 !== void 0 && _this$currentPage2.renderTitle) {
|
|
484
501
|
return this._headerTitleLabelId;
|
|
485
502
|
}
|
|
486
503
|
|
|
@@ -791,7 +808,7 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
791
808
|
});
|
|
792
809
|
}
|
|
793
810
|
renderOption(option, getOptionProps, getDisabledOptionProps, groupProps) {
|
|
794
|
-
var _this$
|
|
811
|
+
var _this$currentPage3, _optionProps$renderBe, _optionProps$renderBe2, _optionProps$renderAf, _optionProps$renderAf2;
|
|
795
812
|
const styles = this.props.styles;
|
|
796
813
|
let isSelected = false;
|
|
797
814
|
const _option$props = option.props,
|
|
@@ -851,7 +868,7 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
851
868
|
};
|
|
852
869
|
const isOptionDisabled = id !== this._headerBackId && (
|
|
853
870
|
// Back nav is never disabled
|
|
854
|
-
this.props.disabled || ((_this$
|
|
871
|
+
this.props.disabled || ((_this$currentPage3 = this.currentPage) === null || _this$currentPage3 === void 0 ? void 0 : _this$currentPage3.disabled) || (groupProps === null || groupProps === void 0 ? void 0 : groupProps.disabled) || disabled);
|
|
855
872
|
|
|
856
873
|
// display option as disabled
|
|
857
874
|
if (isOptionDisabled) {
|
|
@@ -1193,11 +1210,11 @@ let Drilldown = exports.Drilldown = (_dec = (0, _withDeterministicId.withDetermi
|
|
|
1193
1210
|
offsetX: offsetX,
|
|
1194
1211
|
offsetY: offsetY,
|
|
1195
1212
|
defaultFocusElement: () => {
|
|
1196
|
-
var _this$
|
|
1213
|
+
var _this$getFirstOption2, _this$_popover2, _this$_popover2$_cont;
|
|
1197
1214
|
if (!this.currentPage) return null;
|
|
1198
1215
|
const actionLabel = (0, _callRenderProp.callRenderProp)(this.currentPage.renderActionLabel);
|
|
1199
1216
|
// Use action ID if exists, otherwise first non-action option's ID
|
|
1200
|
-
const targetId = actionLabel ? this._headerActionId : (_this$
|
|
1217
|
+
const targetId = actionLabel ? this._headerActionId : (_this$getFirstOption2 = this.getFirstOption()) === null || _this$getFirstOption2 === void 0 ? void 0 : _this$getFirstOption2.props.id;
|
|
1201
1218
|
if (!targetId) return null;
|
|
1202
1219
|
return (_this$_popover2 = this._popover) === null || _this$_popover2 === void 0 ? void 0 : (_this$_popover2$_cont = _this$_popover2._contentElement) === null || _this$_popover2$_cont === void 0 ? void 0 : _this$_popover2$_cont.querySelector(`#${CSS.escape(targetId)}`);
|
|
1203
1220
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-drilldown",
|
|
3
|
-
"version": "10.19.1-snapshot-
|
|
3
|
+
"version": "10.19.1-snapshot-3",
|
|
4
4
|
"description": "A drilldown menu component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,29 +24,29 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.26.0",
|
|
27
|
-
"@instructure/console": "10.19.1-snapshot-
|
|
28
|
-
"@instructure/emotion": "10.19.1-snapshot-
|
|
29
|
-
"@instructure/shared-types": "10.19.1-snapshot-
|
|
30
|
-
"@instructure/ui-dom-utils": "10.19.1-snapshot-
|
|
31
|
-
"@instructure/ui-icons": "10.19.1-snapshot-
|
|
32
|
-
"@instructure/ui-options": "10.19.1-snapshot-
|
|
33
|
-
"@instructure/ui-popover": "10.19.1-snapshot-
|
|
34
|
-
"@instructure/ui-position": "10.19.1-snapshot-
|
|
35
|
-
"@instructure/ui-prop-types": "10.19.1-snapshot-
|
|
36
|
-
"@instructure/ui-react-utils": "10.19.1-snapshot-
|
|
37
|
-
"@instructure/ui-selectable": "10.19.1-snapshot-
|
|
38
|
-
"@instructure/ui-testable": "10.19.1-snapshot-
|
|
39
|
-
"@instructure/ui-utils": "10.19.1-snapshot-
|
|
40
|
-
"@instructure/ui-view": "10.19.1-snapshot-
|
|
27
|
+
"@instructure/console": "10.19.1-snapshot-3",
|
|
28
|
+
"@instructure/emotion": "10.19.1-snapshot-3",
|
|
29
|
+
"@instructure/shared-types": "10.19.1-snapshot-3",
|
|
30
|
+
"@instructure/ui-dom-utils": "10.19.1-snapshot-3",
|
|
31
|
+
"@instructure/ui-icons": "10.19.1-snapshot-3",
|
|
32
|
+
"@instructure/ui-options": "10.19.1-snapshot-3",
|
|
33
|
+
"@instructure/ui-popover": "10.19.1-snapshot-3",
|
|
34
|
+
"@instructure/ui-position": "10.19.1-snapshot-3",
|
|
35
|
+
"@instructure/ui-prop-types": "10.19.1-snapshot-3",
|
|
36
|
+
"@instructure/ui-react-utils": "10.19.1-snapshot-3",
|
|
37
|
+
"@instructure/ui-selectable": "10.19.1-snapshot-3",
|
|
38
|
+
"@instructure/ui-testable": "10.19.1-snapshot-3",
|
|
39
|
+
"@instructure/ui-utils": "10.19.1-snapshot-3",
|
|
40
|
+
"@instructure/ui-view": "10.19.1-snapshot-3",
|
|
41
41
|
"prop-types": "^15.8.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@instructure/ui-axe-check": "10.19.1-snapshot-
|
|
45
|
-
"@instructure/ui-babel-preset": "10.19.1-snapshot-
|
|
46
|
-
"@instructure/ui-color-utils": "10.19.1-snapshot-
|
|
47
|
-
"@instructure/ui-scripts": "10.19.1-snapshot-
|
|
48
|
-
"@instructure/ui-test-utils": "10.19.1-snapshot-
|
|
49
|
-
"@instructure/ui-themes": "10.19.1-snapshot-
|
|
44
|
+
"@instructure/ui-axe-check": "10.19.1-snapshot-3",
|
|
45
|
+
"@instructure/ui-babel-preset": "10.19.1-snapshot-3",
|
|
46
|
+
"@instructure/ui-color-utils": "10.19.1-snapshot-3",
|
|
47
|
+
"@instructure/ui-scripts": "10.19.1-snapshot-3",
|
|
48
|
+
"@instructure/ui-test-utils": "10.19.1-snapshot-3",
|
|
49
|
+
"@instructure/ui-themes": "10.19.1-snapshot-3",
|
|
50
50
|
"@testing-library/jest-dom": "^6.6.3",
|
|
51
51
|
"@testing-library/react": "^16.0.1",
|
|
52
52
|
"@testing-library/user-event": "^14.5.2",
|
package/src/Drilldown/index.tsx
CHANGED
|
@@ -893,7 +893,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
|
|
|
893
893
|
// Use action ID if exists, otherwise first non-action option's ID
|
|
894
894
|
const targetId = actionLabel
|
|
895
895
|
? this._headerActionId
|
|
896
|
-
: this.
|
|
896
|
+
: this.getFirstOption()?.props.id
|
|
897
897
|
setTimeout(() => {
|
|
898
898
|
this.setState({
|
|
899
899
|
highlightedOptionId: targetId
|
|
@@ -911,6 +911,24 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
|
|
|
911
911
|
}
|
|
912
912
|
}
|
|
913
913
|
|
|
914
|
+
getFirstOption = () => {
|
|
915
|
+
const children = Children.toArray(this.currentPage?.children)
|
|
916
|
+
|
|
917
|
+
const child = children[0]
|
|
918
|
+
if (!child) return undefined
|
|
919
|
+
|
|
920
|
+
// If it's a regular option, return it
|
|
921
|
+
if (matchComponentTypes<OptionChild>(child, [DrilldownOption])) {
|
|
922
|
+
return child
|
|
923
|
+
}
|
|
924
|
+
// If it's a group, get its options
|
|
925
|
+
if (matchComponentTypes<GroupChild>(child, [Drilldown.Group])) {
|
|
926
|
+
const groupOptions = Children.toArray(child.props.children)
|
|
927
|
+
return groupOptions[0] as OptionChild
|
|
928
|
+
}
|
|
929
|
+
return undefined
|
|
930
|
+
}
|
|
931
|
+
|
|
914
932
|
renderList(
|
|
915
933
|
getOptionProps: SelectableRender['getOptionProps'],
|
|
916
934
|
getDisabledOptionProps: SelectableRender['getDisabledOptionProps']
|
|
@@ -1512,7 +1530,7 @@ class Drilldown extends Component<DrilldownProps, DrilldownState> {
|
|
|
1512
1530
|
// Use action ID if exists, otherwise first non-action option's ID
|
|
1513
1531
|
const targetId = actionLabel
|
|
1514
1532
|
? this._headerActionId
|
|
1515
|
-
: this.
|
|
1533
|
+
: this.getFirstOption()?.props.id
|
|
1516
1534
|
|
|
1517
1535
|
if (!targetId) return null
|
|
1518
1536
|
return this._popover?._contentElement?.querySelector(
|