Skip to content

Commit

Permalink
docs(inputsearch): add comments for context
Browse files Browse the repository at this point in the history
  • Loading branch information
masoudmanson committed Sep 21, 2023
1 parent d1dcf20 commit cbfab43
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/components/src/core/Autocomplete/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ const Autocomplete = <
...params.InputProps.ref,
endAdornment: (
<StyledInputAdornment position="end">
{/**
* (masoudmansdon): Because the Autocomplete component overrides the
* InputSearch's endAdornment, we must also include the clear IconButton here.
*/}
{inputValue && (
<ButtonIcon
aria-label="clear-button"
Expand Down Expand Up @@ -209,6 +213,10 @@ const Autocomplete = <

function clearInput() {
setInputValue("");
/**
* (masoudmanson): Because we are manually firing this event,
* we must build a onChange event to transmit the updated value to onChange listeners.
*/
if (onInputChange)
onInputChange(
{ target: { value: "" } } as React.ChangeEvent<HTMLInputElement>,
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/core/InputSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ const InputSearch = forwardRef<HTMLDivElement, InputSearchProps>(

if (handleSubmit) handleSubmit("");

/**
* (masoudmanson): Because we are manually firing this event,
* we must build a onChange event to transmit the updated value to onChange listeners.
*/
if (onChange) {
onChange({
target: { value: "" },
Expand Down Expand Up @@ -130,6 +134,10 @@ const InputSearch = forwardRef<HTMLDivElement, InputSearchProps>(
onChange={handleChange}
onKeyDown={handleKeyPress}
intent={intent}
/**
* (masoudmanson): This prevents the browser's default auto completion
* menu from being displayed for the InputSearch.
*/
autoComplete="off"
{...rest}
/>
Expand Down

0 comments on commit cbfab43

Please sign in to comment.