Skip to content
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

feat(applauncher): replaced favorites input with search input #8293

Merged
merged 3 commits into from
Nov 7, 2022
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
@@ -1,7 +1,6 @@
import * as React from 'react';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/react-styles/css/components/AppLauncher/app-launcher';
import formStyles from '@patternfly/react-styles/css/components/FormControl/form-control';
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon';
import { DropdownDirection, DropdownPosition, DropdownToggle, DropdownContext } from '../Dropdown';
import { DropdownWithContext } from '../Dropdown/DropdownWithContext';
Expand All @@ -10,6 +9,7 @@ import { ApplicationLauncherSeparator } from './ApplicationLauncherSeparator';
import { ApplicationLauncherItem } from './ApplicationLauncherItem';
import { ApplicationLauncherContext } from './ApplicationLauncherContext';
import { createRenderableFavorites, extendItemsWithFavorite } from '../../helpers/favorites';
import { SearchInput } from '../SearchInput';

export interface ApplicationLauncherProps extends React.HTMLProps<HTMLDivElement> {
/** Additional element css classes */
Expand Down Expand Up @@ -93,13 +93,7 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
<div key="search" className={css(styles.appLauncherMenuSearch)}>
<ApplicationLauncherItem
customChild={
<input
type="search"
className={css(formStyles.formControl)}
placeholder={searchPlaceholderText}
onChange={e => onSearch(e.target.value)}
{...searchProps}
></input>
<SearchInput placeholder={searchPlaceholderText} onChange={value => onSearch(value)} {...searchProps} />
}
></ApplicationLauncherItem>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface ApplicationLauncherItemProps {
ariaIsNotFavoriteLabel?: string;
/** ID of the item. Required for tracking favorites. */
id?: string;
/** Custom item rendering that receives the ApplicationLauncherContext */
customChild?: React.ReactNode;
/** Flag indicating if hitting enter triggers an arrow down key press. Automatically passed to favorites list items. */
enterTriggersArrowDown?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ export const ApplicationLauncherFavoritesAndSearch: React.FunctionComponent = ()
const [favorites, setFavorites] = React.useState<string[]>([]);
const [filteredItems, setFilteredItems] = React.useState<React.ReactNode[]>(null);

const onToggle = (isOpen: boolean) => setIsOpen(isOpen);
const onToggle = (isOpen: boolean) => {
setIsOpen(isOpen);
setFilteredItems(null);
};

const onFavorite = (itemId: string, isFavorite: boolean) => {
let updatedFavorites: string[] = [...favorites, itemId];
Expand Down