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(DualListSelector, SearchInput): use SearchInput in DLS, add type prop to SearchInput #8040

Merged
merged 5 commits into from
Sep 30, 2022
Merged
Changes from 1 commit
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
Next Next commit
feat(DualListSelector,SearchInput): use SearchInput in DualListSelect…
…or, add type to SearchInput
  • Loading branch information
kmcfaul committed Sep 30, 2022
commit 4b76c69500e447b2aef72018f4be87ba10027418
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import * as React from 'react';
import styles from '@patternfly/react-styles/css/components/DualListSelector/dual-list-selector';
import { css } from '@patternfly/react-styles';
import formStyles from '@patternfly/react-styles/css/components/FormControl/form-control';
import { DualListSelectorTree, DualListSelectorTreeItemData } from './DualListSelectorTree';
import { getUniqueId } from '../../helpers';
import { DualListSelectorListWrapper } from './DualListSelectorListWrapper';
import { DualListSelectorContext, DualListSelectorPaneContext } from './DualListSelectorContext';
import { DualListSelectorList } from './DualListSelectorList';
import { SearchInput } from '../SearchInput';

/** Acts as the container for a list of options that are either available or chosen,
* depending on the pane type (available or chosen). A search input and other actions,
@@ -90,8 +90,7 @@ export const DualListSelectorPane: React.FunctionComponent<DualListSelectorPaneP
const { isTree } = React.useContext(DualListSelectorContext);

// only called when search input is dynamically built
const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newValue = e.target.value;
const onChange = (newValue: string, e: React.FormEvent<HTMLInputElement>) => {
let filtered: React.ReactNode[];
if (isTree) {
filtered = options
@@ -160,12 +159,11 @@ export const DualListSelectorPane: React.FunctionComponent<DualListSelectorPaneP
{searchInput ? (
searchInput
) : (
<input
className={css(formStyles.formControl, formStyles.modifiers.search)}
type="search"
<SearchInput
onChange={isDisabled ? undefined : onChange}
isDisabled={isDisabled}
aria-label={searchInputAriaLabel}
disabled={isDisabled}
type="search"
/>
)}
</div>
15 changes: 15 additions & 0 deletions packages/react-core/src/components/SearchInput/SearchInput.tsx
Original file line number Diff line number Diff line change
@@ -70,6 +70,19 @@ export interface SearchInputProps extends Omit<React.HTMLProps<HTMLDivElement>,
hasWordsAttrLabel?: React.ReactNode;
/** A suggestion for autocompleting. */
hint?: string;
/** Type of the input */
type?:
| 'text'
| 'date'
| 'datetime-local'
| 'email'
| 'month'
| 'number'
| 'password'
| 'search'
| 'tel'
| 'time'
| 'url';
/** @hide A reference object to attach to the input box. */
innerRef?: React.RefObject<any>;
/** A flag for controlling the open state of a custom advanced search implementation. */
@@ -147,6 +160,7 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
isDisabled = false,
appendTo,
removeFindDomNode = false,
type = 'text',
...props
}: SearchInputProps) => {
const [isSearchMenuOpen, setIsSearchMenuOpen] = React.useState(false);
@@ -263,6 +277,7 @@ const SearchInputBase: React.FunctionComponent<SearchInputProps> = ({
aria-label={ariaLabel}
onKeyDown={onEnter}
onChange={onChangeHandler}
type={type}
/>
{renderUtilities && (
<TextInputGroupUtilities>