Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
261d0cd8
Commit
261d0cd8
authored
Aug 29, 2023
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `disabled` prop to `Menu`
parent
06678e64
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
Menu.tsx
src/sidebar/components/Menu.tsx
+4
-0
Menu-test.js
src/sidebar/components/test/Menu-test.js
+6
-0
No files found.
src/sidebar/components/Menu.tsx
View file @
261d0cd8
...
@@ -51,6 +51,8 @@ export type MenuProps = {
...
@@ -51,6 +51,8 @@ export type MenuProps = {
*/
*/
defaultOpen
?:
boolean
;
defaultOpen
?:
boolean
;
disabled
?:
boolean
;
/** Whether to render an (arrow) indicator next to the Menu label */
/** Whether to render an (arrow) indicator next to the Menu label */
menuIndicator
?:
boolean
;
menuIndicator
?:
boolean
;
...
@@ -98,6 +100,7 @@ export default function Menu({
...
@@ -98,6 +100,7 @@ export default function Menu({
containerPositioned
=
true
,
containerPositioned
=
true
,
contentClass
,
contentClass
,
defaultOpen
=
false
,
defaultOpen
=
false
,
disabled
=
false
,
label
,
label
,
open
,
open
,
onOpenChanged
,
onOpenChanged
,
...
@@ -201,6 +204,7 @@ export default function Menu({
...
@@ -201,6 +204,7 @@ export default function Menu({
},
},
)
}
)
}
data
-
testid=
"menu-toggle-button"
data
-
testid=
"menu-toggle-button"
disabled=
{
disabled
}
onMouseDown=
{
toggleMenu
}
onMouseDown=
{
toggleMenu
}
onClick=
{
toggleMenu
}
onClick=
{
toggleMenu
}
aria
-
label=
{
title
}
aria
-
label=
{
title
}
...
...
src/sidebar/components/test/Menu-test.js
View file @
261d0cd8
...
@@ -52,6 +52,12 @@ describe('Menu', () => {
...
@@ -52,6 +52,12 @@ describe('Menu', () => {
assert
.
isFalse
(
isOpen
(
wrapper
));
assert
.
isFalse
(
isOpen
(
wrapper
));
});
});
it
(
'disables menu if `disabled` prop is true'
,
()
=>
{
const
wrapper
=
createMenu
({
disabled
:
true
});
const
toggle
=
wrapper
.
find
(
toggleSelector
);
assert
.
isTrue
(
toggle
.
prop
(
'disabled'
));
});
it
(
'leaves the management of open/closed state to parent component if `open` prop present'
,
()
=>
{
it
(
'leaves the management of open/closed state to parent component if `open` prop present'
,
()
=>
{
// When `open` is present, `Menu` will invoke `onOpenChanged` on interactions
// When `open` is present, `Menu` will invoke `onOpenChanged` on interactions
// but will not modify the its open state directly.
// but will not modify the its open state directly.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment