-
Notifications
You must be signed in to change notification settings - Fork 381
feat(Toolbar,OverflowMenu): support responsive height vis breakpoints #12347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,111 @@ | ||||||
| import { useRef, useState } from 'react'; | ||||||
| import { | ||||||
| OverflowMenu, | ||||||
| OverflowMenuControl, | ||||||
| OverflowMenuContent, | ||||||
| OverflowMenuGroup, | ||||||
| OverflowMenuItem, | ||||||
| OverflowMenuDropdownItem, | ||||||
| MenuToggle, | ||||||
| Slider, | ||||||
| SliderOnChangeEvent, | ||||||
| Dropdown, | ||||||
| DropdownList | ||||||
| } from '@patternfly/react-core'; | ||||||
| import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; | ||||||
|
|
||||||
| export const OverflowMenuBreakpointOnContainerHeight: React.FunctionComponent = () => { | ||||||
| const [isOpen, setIsOpen] = useState(false); | ||||||
| const [containerHeight, setContainerHeight] = useState(100); | ||||||
| const containerRef = useRef<HTMLDivElement>(null); | ||||||
|
|
||||||
| const onToggle = () => { | ||||||
| setIsOpen(!isOpen); | ||||||
| }; | ||||||
|
|
||||||
| const onSelect = () => { | ||||||
| setIsOpen(!isOpen); | ||||||
| }; | ||||||
|
|
||||||
| const onChange = (_event: SliderOnChangeEvent, value: number) => { | ||||||
| setContainerHeight(value); | ||||||
| }; | ||||||
|
|
||||||
| const containerStyles = { | ||||||
| height: `${containerHeight}%`, | ||||||
| padding: '1rem', | ||||||
| borderWidth: '2px', | ||||||
| borderStyle: 'dashed' | ||||||
| }; | ||||||
|
|
||||||
| const dropdownItems = [ | ||||||
| <OverflowMenuDropdownItem itemId={0} key="item1" isShared> | ||||||
| Item 1 | ||||||
| </OverflowMenuDropdownItem>, | ||||||
| <OverflowMenuDropdownItem itemId={1} key="item2" isShared> | ||||||
| Item 2 | ||||||
| </OverflowMenuDropdownItem>, | ||||||
| <OverflowMenuDropdownItem itemId={2} key="item3" isShared> | ||||||
| Item 3 | ||||||
| </OverflowMenuDropdownItem>, | ||||||
| <OverflowMenuDropdownItem itemId={3} key="item4" isShared> | ||||||
| Item 4 | ||||||
| </OverflowMenuDropdownItem>, | ||||||
| <OverflowMenuDropdownItem itemId={4} key="item5" isShared> | ||||||
| Item 5 | ||||||
| </OverflowMenuDropdownItem> | ||||||
| ]; | ||||||
|
|
||||||
| return ( | ||||||
| <> | ||||||
| <div style={{ height: '100%', maxHeight: '400px' }}> | ||||||
| <div> | ||||||
| <span id="overflowMenu-hasBreakpointOnContainer-height-slider-label">Current container width</span>:{' '} | ||||||
| {containerHeight}% | ||||||
| </div> | ||||||
| <Slider | ||||||
| value={containerHeight} | ||||||
| onChange={onChange} | ||||||
| max={100} | ||||||
| min={20} | ||||||
| step={20} | ||||||
| showTicks | ||||||
| showBoundaries={false} | ||||||
| aria-labelledby="overflowMenu-hasBreakpointOnContainer-height-slider-label" | ||||||
| /> | ||||||
| </div> | ||||||
| <div ref={containerRef} id="height-breakpoint-reference-container" style={containerStyles}> | ||||||
| <OverflowMenu breakpointReference={containerRef} breakpoint="sm"> | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, locate and examine the OverflowMenu.tsx file to verify the height logic
fd -t f "OverflowMenu.tsx" --path "*components/OverflowMenu*" | grep -v exampleRepository: patternfly/patternfly-react Length of output: 304 🏁 Script executed: # Read the example file around line 78 to verify the prop usage
cat -n packages/react-core/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainerHeight.tsx | sed -n '70,85p'Repository: patternfly/patternfly-react Length of output: 906 🏁 Script executed: # Check the OverflowMenu.tsx implementation around lines 79-116
cat -n packages/react-core/src/components/OverflowMenu/OverflowMenu.tsx | sed -n '75,120p'Repository: patternfly/patternfly-react Length of output: 1856 🏁 Script executed: # Check the documentation file
fd -t f "OverflowMenu.md" --path "*OverflowMenu*"Repository: patternfly/patternfly-react Length of output: 304 🏁 Script executed: # Check line 63 for the label issue
cat -n packages/react-core/src/components/OverflowMenu/examples/OverflowMenuBreakpointOnContainerHeight.tsx | sed -n '60,70p'Repository: patternfly/patternfly-react Length of output: 506 🏁 Script executed: # Find and read the OverflowMenu.md documentation
find . -name "OverflowMenu.md" -type fRepository: patternfly/patternfly-react Length of output: 145 🏁 Script executed: # Search for documentation about the height breakpoint example
rg "breakpointReference.*isVertical|isVertical.*breakpointReference|container height" -A 3 -B 3 --type md packages/react-core/src/components/OverflowMenu/Repository: patternfly/patternfly-react Length of output: 1023 Pass
Additionally, the slider label on line 63 says "Current container width" but should say "Current container height" for this example. 🩹 Suggested fix- <OverflowMenu breakpointReference={containerRef} breakpoint="sm">
+ <OverflowMenu breakpointReference={containerRef} breakpoint="sm" isVertical>Also update line 63 label from "Current container width" to "Current container height". 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| <OverflowMenuContent> | ||||||
| <OverflowMenuItem>Item 1</OverflowMenuItem> | ||||||
| <OverflowMenuItem>Item 2</OverflowMenuItem> | ||||||
| <OverflowMenuGroup> | ||||||
| <OverflowMenuItem>Item 3</OverflowMenuItem> | ||||||
| <OverflowMenuItem>Item 4</OverflowMenuItem> | ||||||
| <OverflowMenuItem>Item 5</OverflowMenuItem> | ||||||
| </OverflowMenuGroup> | ||||||
| </OverflowMenuContent> | ||||||
| <OverflowMenuControl> | ||||||
| <Dropdown | ||||||
| onSelect={onSelect} | ||||||
| toggle={(toggleRef) => ( | ||||||
| <MenuToggle | ||||||
| ref={toggleRef} | ||||||
| aria-label="Height breakpoint on container example overflow menu" | ||||||
| variant="plain" | ||||||
| onClick={onToggle} | ||||||
| isExpanded={isOpen} | ||||||
| icon={<EllipsisVIcon />} | ||||||
| /> | ||||||
| )} | ||||||
| isOpen={isOpen} | ||||||
| onOpenChange={(isOpen) => setIsOpen(isOpen)} | ||||||
| > | ||||||
| <DropdownList>{dropdownItems}</DropdownList> | ||||||
| </Dropdown> | ||||||
| </OverflowMenuControl> | ||||||
| </OverflowMenu> | ||||||
| </div> | ||||||
| </> | ||||||
| ); | ||||||
| }; | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| import { useState } from 'react'; | ||
| import { | ||
| OverflowMenu, | ||
| OverflowMenuControl, | ||
| OverflowMenuContent, | ||
| OverflowMenuGroup, | ||
| OverflowMenuItem, | ||
| OverflowMenuDropdownItem, | ||
| MenuToggle, | ||
| Dropdown, | ||
| DropdownList | ||
| } from '@patternfly/react-core'; | ||
| import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; | ||
|
|
||
| export const OverflowMenuSimpleVertical: React.FunctionComponent = () => { | ||
| const [isOpen, setIsOpen] = useState(false); | ||
|
|
||
| const onToggle = () => { | ||
| setIsOpen(!isOpen); | ||
| }; | ||
|
|
||
| const onSelect = () => { | ||
| setIsOpen(!isOpen); | ||
| }; | ||
|
|
||
| const dropdownItems = [ | ||
| <OverflowMenuDropdownItem itemId={0} key="item1" isShared> | ||
| Item 1 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={1} key="item2" isShared> | ||
| Item 2 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={2} key="item3" isShared> | ||
| Item 3 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={3} key="item4" isShared> | ||
| Item 4 | ||
| </OverflowMenuDropdownItem>, | ||
| <OverflowMenuDropdownItem itemId={5} key="item5" isShared> | ||
| Item 5 | ||
| </OverflowMenuDropdownItem> | ||
| ]; | ||
|
|
||
| return ( | ||
| <OverflowMenu breakpoint="lg" isVertical> | ||
| <OverflowMenuContent> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| <OverflowMenuGroup> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| <OverflowMenuItem>Item</OverflowMenuItem> | ||
| </OverflowMenuGroup> | ||
| </OverflowMenuContent> | ||
| <OverflowMenuControl> | ||
| <Dropdown | ||
| onSelect={onSelect} | ||
| toggle={(toggleRef) => ( | ||
| <MenuToggle | ||
| ref={toggleRef} | ||
| aria-label="Simple example overflow menu" | ||
| variant="plain" | ||
| onClick={onToggle} | ||
| isExpanded={isOpen} | ||
| icon={<EllipsisVIcon />} | ||
| /> | ||
| )} | ||
| isOpen={isOpen} | ||
| onOpenChange={(isOpen) => setIsOpen(isOpen)} | ||
| > | ||
| <DropdownList>{dropdownItems}</DropdownList> | ||
| </Dropdown> | ||
| </OverflowMenuControl> | ||
| </OverflowMenu> | ||
| ); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label still says width.
This is the height example, so the readout text is currently misleading.
🩹 Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents