Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export const MenuWithDrilldown: React.FunctionComponent = () => {
value={startInput}
aria-label="Filter menu items"
onChange={(_event, value) => handleStartTextInputChange(value)}
onClear={() => handleStartTextInputChange('')}
/>
</MenuSearchInput>
</MenuSearch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const MenuFilteringWithSearchInput: React.FunctionComponent = () => {
value={input}
aria-label="Filter menu items"
onChange={(_event, value) => handleTextInputChange(value)}
onClear={() => handleTextInputChange('')}
/>
</MenuSearchInput>
</MenuSearch>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { Fragment } from 'react';
import { Fragment, useState } from 'react';
import { Toolbar, ToolbarItem, ToolbarContent } from '@patternfly/react-core';
import { Button, SearchInput } from '@patternfly/react-core';

export const ToolbarItems: React.FunctionComponent = () => {
export const ToolbarItems = () => {
const [searchValue, setSearchValue] = useState('');

const items = (
<Fragment>
<ToolbarItem>
<SearchInput aria-label="Items example search input" />
<SearchInput
aria-label="Items example search input"
value={searchValue}
onChange={(_event, value) => setSearchValue(value)}
onClear={() => setSearchValue('')}
/>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Action</Button>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { Fragment } from 'react';
import { Fragment, useState } from 'react';
import { Toolbar, ToolbarItem, ToolbarContent } from '@patternfly/react-core';
import { Button, SearchInput } from '@patternfly/react-core';

export const ToolbarItems: React.FunctionComponent = () => {
export const ToolbarItems = () => {
const [searchValue, setSearchValue] = useState('');

const items = (
<Fragment>
<ToolbarItem>
<SearchInput aria-label="Items example search input" />
<SearchInput
aria-label="Items example search input"
value={searchValue}
onChange={(_event, value) => setSearchValue(value)}
onClear={() => setSearchValue('')}
/>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Action</Button>
</ToolbarItem>
<ToolbarItem variant="separator" />
<ToolbarItem>
<Button variant="primary">Action</Button>
<Button variant="primary">Action2</Button>
</ToolbarItem>
</Fragment>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Fragment, useState } from 'react';
import { Toolbar, ToolbarItem, ToolbarContent, SearchInput, Checkbox } from '@patternfly/react-core';

export const ToolbarSticky: React.FunctionComponent = () => {
export const ToolbarSticky = () => {
const [isSticky, setIsSticky] = useState(true);
const [showEvenOnly, setShowEvenOnly] = useState(true);
const [searchValue, setSearchValue] = useState('');
const array = Array.from(Array(30), (_, x) => x); // create array of numbers from 1-30 for demo purposes
const numbers = showEvenOnly ? array.filter((number) => number % 2 === 0) : array;

Expand All @@ -13,7 +14,12 @@ export const ToolbarSticky: React.FunctionComponent = () => {
<Toolbar id="toolbar-sticky" inset={{ default: 'insetNone' }} isSticky={isSticky}>
<ToolbarContent>
<ToolbarItem>
<SearchInput aria-label="Sticky example search input" />
<SearchInput
aria-label="Sticky example search input"
value={searchValue}
onChange={(_event, value) => setSearchValue(value)}
onClear={() => setSearchValue('')}
/>
</ToolbarItem>
<ToolbarItem alignSelf="center">
<Checkbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export const InlineSearchFilterMenuDemo: React.FunctionComponent = () => {
value={input}
aria-label="Filter menu items"
onChange={(_event, value) => handleTextInputChange(value)}
onClear={(event) => {
event.stopPropagation();
handleTextInputChange('');
}}
/>
</MenuSearchInput>
</MenuSearch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const DataListExpandableControlInToolbar: React.FunctionComponent = () =>
const [isOpen2, setIsOpen2] = useState(false);
const [isOpen3, setIsOpen3] = useState(false);
const [allExpanded, setAllExpanded] = useState(false);
const [searchValue, setSearchValue] = useState('');

const onToggleAll = () => {
setAllExpanded((prevAllExpanded) => !prevAllExpanded);
Expand Down Expand Up @@ -103,7 +104,12 @@ export const DataListExpandableControlInToolbar: React.FunctionComponent = () =>
</Tooltip>
</ToolbarItem>
<ToolbarItem>
<SearchInput aria-label="search input example" />
<SearchInput
aria-label="search input example"
value={searchValue}
onChange={(_event, value) => setSearchValue(value)}
onClear={() => setSearchValue('')}
/>
</ToolbarItem>
<ToolbarItem>
<Button variant="secondary">Action</Button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export const MastheadWithUtilitiesAndUserDropdownMenu: React.FunctionComponent =
const [refFullOptions, setRefFullOptions] = useState<Element[]>();
const [favorites, setFavorites] = useState<string[]>([]);
const [filteredIds, setFilteredIds] = useState<string[]>(['*']);
const [searchValue, setSearchValue] = useState('');
const menuRef = useRef<HTMLDivElement>(null);
const toggleRef = useRef<HTMLButtonElement>(null);

Expand Down Expand Up @@ -297,6 +298,7 @@ export const MastheadWithUtilitiesAndUserDropdownMenu: React.FunctionComponent =
};

const onTextChange = (textValue: string) => {
setSearchValue(textValue);
if (textValue === '') {
setFilteredIds(['*']);
return;
Expand Down Expand Up @@ -331,7 +333,15 @@ export const MastheadWithUtilitiesAndUserDropdownMenu: React.FunctionComponent =
// eslint-disable-next-line no-console
<Menu ref={menuRef} onActionClick={onFavorite} onSelect={(_ev, itemId) => console.log('selected', itemId)}>
<MenuSearchInput>
<SearchInput aria-label="Filter menu items" onChange={(_event, value) => onTextChange(value)} />
<SearchInput
aria-label="Filter menu items"
value={searchValue}
onChange={(_event, value) => onTextChange(value)}
onClear={(event) => {
event.stopPropagation();
onTextChange('');
}}
/>
</MenuSearchInput>
<Divider />
<MenuContent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export class MenuDemo extends Component {
value={input}
aria-label="filterable-example-with-text-input"
onChange={(_event, value) => this.handleTextInputChange(value, 'input')}
onClear={() => this.handleTextInputChange('', 'input')}
/>
</MenuSearchInput>
</MenuSearch>
Expand Down
Loading