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

style(inputsearch): change default html clear icon #607

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ exports[`<Autocomplete /> Default story renders snapshot 1`] = `
Search by label
</label>
<div
class="MuiFormControl-root MuiTextField-root css-zhsnsf-MuiFormControl-root-MuiTextField-root"
class="MuiFormControl-root MuiTextField-root css-1yyp8n-MuiFormControl-root-MuiTextField-root"
>
<div
class="MuiInputBase-root MuiOutlinedInput-root MuiInputBase-colorPrimary MuiInputBase-formControl MuiInputBase-sizeSmall MuiInputBase-adornedEnd css-o9k5xi-MuiInputBase-root-MuiOutlinedInput-root"
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/core/InputSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ const InputSearch = forwardRef<HTMLDivElement, InputSearchProps>(
sdsStyle={sdsStyle}
sdsStage={hasValue ? "userInput" : "default"}
onChange={handleChange}
onKeyPress={handleKeyPress}
onKeyDown={handleKeyPress}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The onKeyPress event has been deprecated and replaced by the newer onKeyDown event.

intent={intent}
autoComplete="off"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents the browser's default auto completion menu from being displayed for the InputSearch.

Screenshot 2023-09-21 at 5 08 16 PM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add this comment in the code too for context!

{...rest}
/>
</>
Expand Down
13 changes: 13 additions & 0 deletions packages/components/src/core/InputSearch/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TextField,
} from "@mui/material";
import { styled } from "@mui/material/styles";
import xMark from "../../common/svgs/IconXMarkSmall.svg";
import {
CommonThemeProps,
fontBodyM,
Expand Down Expand Up @@ -116,6 +117,18 @@ export const StyledSearchBase = styled(TextField, {
min-width: 120px;
display: block;

[type="search"]::-webkit-search-cancel-button {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part hides the default HTML clear icon.

-webkit-appearance: none;
appearance: none;
height: 14px;
width: 14px;
background-color: ${colors?.primary[400]};
-webkit-mask-image: url(${xMark});
mask-image: url(${xMark});
background-size: 14px 14px;
cursor: pointer;
}

.${outlinedInputClasses.root} {
.${outlinedInputClasses.notchedOutline} {
border: ${borders?.gray[400]};
Expand Down
Loading