Class BaseSearchInput<T extends BaseSearchInput<T>>
java.lang.Object
org.patternfly.component.BaseComponent<HTMLElement, T>
org.patternfly.component.textinputgroup.BaseTextInputGroup<T>
org.patternfly.component.textinputgroup.BaseSearchInput<T>
- All Implemented Interfaces:
Attachable, ElementAttributeMethods<HTMLElement, T>, ElementClassListMethods<HTMLElement, T>, ElementConsumerMethods<HTMLElement, T>, ElementContainerMethods<HTMLElement, T>, ElementEventMethods<HTMLElement, T>, ElementIdMethods<HTMLElement, T>, ElementQueryMethods<HTMLElement>, HTMLElementAttributeMethods<HTMLElement, T>, HTMLElementDataMethods<HTMLElement, T>, HTMLElementStyleMethods<HTMLElement, T>, HTMLElementVisibilityMethods<HTMLElement, T>, IsElement<HTMLElement>, TypedBuilder<HTMLElement, T>, Component, ComponentIcon<HTMLElement, T>, Expandable<HTMLElement, T>, HasValue<String>, Validatable<HTMLElement, T>, OuiaSupport<HTMLElement, T>, Modifiers.Disabled<HTMLElement, T>, Modifiers.Plain<HTMLElement, T>
- Direct Known Subclasses:
BaseFilterInput, SearchInput
public abstract class BaseSearchInput<T extends BaseSearchInput<T>>
extends BaseTextInputGroup<T>
implements Attachable, Expandable<HTMLElement, T>
Base class for search input components within a
TextInputGroup.
Provides core search input functionality including a clear button, customizable utility visibility, and optional typeahead
support via an attached Menu. When a menu is added, the search input acts as an autocomplete: typing filters menu
items, and selecting an item populates the input field.
-
Method Summary
Modifier and TypeMethodDescriptionAdds a menu to the search input, enabling typeahead functionality.Adds a menu to the search input, enabling typeahead functionality.voidattach(MutationRecord mutationRecord) voidcollapse(boolean fireEvent) voiddetach(MutationRecord mutationRecord) voidexpand(boolean fireEvent) menu()Retrieves the menu associated with this input.Removes the default behavior when the component is cleared.onClear(ComponentHandler<T> onClear) Adds a handler to be executed when the clear action is pressed.onLoaded(ComponentHandler<T> loadedHandler) Adds a handler called when the menu has finished loading its items.onSearch(SearchFilter searchFilter) Sets the search filter used to match menu items against the input value.onToggle(ToggleHandler<T> toggleHandler) Adds a handler called when the typeahead menu is expanded or collapsed.showUtilitiesIf(BiFunction<T, String, Boolean> visibility) Sets the visibility condition for the utility button.stayOpen(StayOpenPredicate stayOpen) Specifies a condition that determines whether the menu should remain open when a menu item is clicked.booleanChecks whether typeahead functionality is active for this input.Same as value(value, false)Methods inherited from class BaseTextInputGroup
add, addUtilities, applyTo, disabled, icon, input, onChange, onInput, onKeydown, onKeyup, placeholder, removeIcon, resetValidation, utilities, validated, valueMethods inherited from class BaseComponent
componentType, element, ouiaComponentType, registerComponentMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ComponentIcon
iconMethods inherited from interface ElementAttributeMethods
aria, aria, aria, attr, attr, attr, role, roleMethods inherited from interface ElementClassListMethods
classList, classList, css, toggle, toggle, toggleMethods inherited from interface ElementConsumerMethods
apply, runMethods inherited from interface ElementContainerMethods
add, add, add, add, addAll, addAll, addAll, addAll, addAll, addAllMethods inherited from interface ElementEventMethods
on, on, onMethods inherited from interface ElementIdMethods
id, uniqueIdMethods inherited from interface ElementQueryMethods
closest, querySelector, querySelectorAllMethods inherited from interface HTMLElementAttributeMethods
titleMethods inherited from interface HTMLElementDataMethods
data, dataMethods inherited from interface HTMLElementVisibilityMethods
hiddenMethods inherited from interface Modifiers.Disabled
disabled, isDisabledMethods inherited from interface Modifiers.Plain
plain, plainMethods inherited from interface OuiaSupport
initOuia, initOuia, ouiaId, ouiaSafe, ouiaTransitionMethods inherited from interface TypedBuilder
that
-
Method Details
-
attach
- Specified by:
attachin interfaceAttachable
-
detach
- Specified by:
detachin interfaceAttachable
-
noDefaultOnClear
Removes the default behavior when the component is cleared. By default, the clear button clears the input field (w/o firing a change event). -
showUtilitiesIf
Sets the visibility condition for the utility button. By default, the button is visible when the input field is not empty. The providedBiFunctiondetermines whether the utility should be visible based on the currentSearchInputinstance and aStringvalue.- Parameters:
visibility- aBiFunctionthat takes theSearchInputinstance and aStringvalue as arguments and returns aBooleanindicating whether the utility should be visible.
-
stayOpen
Specifies a condition that determines whether the menu should remain open when a menu item is clicked. -
onClear
Adds a handler to be executed when the clear action is pressed.- Parameters:
onClear- aComponentHandlerthat defines the behavior to execute on a clear action.
-
onLoaded
Adds a handler called when the menu has finished loading its items. This is relevant for menus with asynchronous item loading. By default, a loaded handler that triggers a search with the current value is already registered.- Parameters:
loadedHandler- aComponentHandlerto execute after the menu items have loaded.
-
onToggle
Adds a handler called when the typeahead menu is expanded or collapsed.- Parameters:
toggleHandler- aToggleHandlerthat receives the toggle event and the current expanded state.
-
collapse
public void collapse(boolean fireEvent) - Specified by:
collapsein interfaceExpandable<HTMLElement, T extends BaseSearchInput<T>>
-
expand
public void expand(boolean fireEvent) - Specified by:
expandin interfaceExpandable<HTMLElement, T extends BaseSearchInput<T>>
-
typeahead
public boolean typeahead()Checks whether typeahead functionality is active for this input. Typeahead is enabled when a menu has been added to the input.- Returns:
trueif typeahead is enabled;falseotherwise.
-
value
Description copied from class:BaseTextInputGroupSame as value(value, false)- Overrides:
valuein classBaseTextInputGroup<T extends BaseSearchInput<T>>
-
value
- Overrides:
valuein classBaseTextInputGroup<T extends BaseSearchInput<T>>
-