Skip to content

Commit

Permalink
feat(ApplicationLauncher): added event param to callbacks (#8756)
Browse files Browse the repository at this point in the history
  • Loading branch information
wise-king-sullyman committed Mar 1, 2023
1 parent c493100 commit 125a002
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export interface ApplicationLauncherProps extends React.HTMLProps<HTMLDivElement
/** ID list of favorited ApplicationLauncherItems */
favorites?: string[];
/** Enables favorites. Callback called when an ApplicationLauncherItem's favorite button is clicked */
onFavorite?: (itemId: string, isFavorite: boolean) => void;
onFavorite?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>, itemId: string, isFavorite: boolean) => void;
/** Enables search. Callback called when text input is entered into search box */
onSearch?: (textInput: string) => void;
onSearch?: (event: React.FormEvent<HTMLInputElement>, textInput: string) => void;
/** Placeholder text for search input */
searchPlaceholderText?: string;
/** Text for search input when no results are found */
Expand Down Expand Up @@ -97,7 +97,7 @@ export class ApplicationLauncher extends React.Component<ApplicationLauncherProp
customChild={
<SearchInput
placeholder={searchPlaceholderText}
onChange={(_event, value) => onSearch(value)}
onChange={onSearch}
{...searchProps}
/>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import * as React from 'react';

export const ApplicationLauncherContext = React.createContext({
// eslint-disable-next-line @typescript-eslint/no-unused-vars
onFavorite: (itemId: string, isFavorite: boolean) => {}
onFavorite: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>, itemId: string, isFavorite: boolean) => {}
});
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export const ApplicationLauncherItem: React.FunctionComponent<ApplicationLaunche
<button
className={css(styles.appLauncherMenuItem, styles.modifiers.action)}
aria-label={isFavorite ? ariaIsFavoriteLabel : ariaIsNotFavoriteLabel}
onClick={() => {
onFavorite((id || getUniqueId('app-launcher-option')).replace('favorite-', ''), isFavorite);
onClick={(event) => {
onFavorite(event, (id || getUniqueId('app-launcher-option')).replace('favorite-', ''), isFavorite);
}}
>
<StarIcon />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const ApplicationLauncherFavoritesAndSearch: React.FunctionComponent = ()
setFilteredItems(null);
};

const onFavorite = (itemId: string, isFavorite: boolean) => {
const onFavorite = (_event: React.MouseEvent<HTMLButtonElement, MouseEvent>, itemId: string, isFavorite: boolean) => {
let updatedFavorites: string[] = [...favorites, itemId];

if (isFavorite) {
Expand All @@ -55,7 +55,7 @@ export const ApplicationLauncherFavoritesAndSearch: React.FunctionComponent = ()
setFavorites(updatedFavorites);
};

const onSearch = (textInput: string) => {
const onSearch = (_event: React.FormEvent<HTMLInputElement>, textInput: string) => {
if (textInput === '') {
setFilteredItems(null);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class ApplicationLauncherFavoritesDemo extends React.Component<null, Appl
isOpen: !this.state.isOpen
});
};
onFavorite = (itemId: string, isFavorite: boolean) => {
onFavorite = (_event: React.MouseEvent<HTMLButtonElement, MouseEvent>, itemId: string, isFavorite: boolean) => {
if (isFavorite) {
this.setState({
favorites: this.state.favorites.filter(id => id !== itemId)
Expand All @@ -68,7 +68,7 @@ export class ApplicationLauncherFavoritesDemo extends React.Component<null, Appl
});
}
};
onSearch = (textInput: string) => {
onSearch = (_event: React.FormEvent<HTMLInputElement>, textInput: string) => {
if (textInput === '') {
this.setState({
filteredItems: null
Expand Down

0 comments on commit 125a002

Please sign in to comment.