Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

Fix font search field (#1776)

Bogdan Chadkin65206a1c4a03
diff --git a/packages/design-system/src/components/search-field.tsx b/packages/design-system/src/components/search-field.tsx
index 4c44209812..0cf71672b8 100644
--- a/packages/design-system/src/components/search-field.tsx
+++ b/packages/design-system/src/components/search-field.tsx
@@ -16,12 +16,20 @@ import { InputField } from "./input-field";
import { IconButton } from "./icon-button";
const SearchIcon = styled(MagnifyingGlassIcon, {
+ // need to center icon vertically
+ display: "block",
color: theme.colors.hint,
padding: theme.spacing[3],
});
const AbortButton = styled(IconButton, {
marginRight: theme.spacing[3],
+ variants: {
+ hidden: {
+ false: { visibility: "hidden" },
+ true: {},
+ },
+ },
});
const SearchFieldBase: ForwardRefRenderFunction<
@@ -44,24 +52,26 @@ const SearchFieldBase: ForwardRefRenderFunction<
<InputField
{...rest}
ref={ref}
- type="search"
+ // search field implements own reset button
+ // type=search does not work here because
+ // brings native reset button
+ type="text"
value={value}
inputRef={inputRef}
prefix={<SearchIcon />}
suffix={
- value.length > 0 ? (
- <AbortButton
- aria-label="Reset search"
- title="Reset search"
- tabIndex={-1}
- onClick={() => {
- setValue("");
- onCancel?.();
- }}
- >
- <CrossCircledFilledIcon />
- </AbortButton>
- ) : null
+ <AbortButton
+ hidden={value.length > 0 ? "true" : "false"}
+ aria-label="Reset search"
+ title="Reset search"
+ tabIndex={-1}
+ onClick={() => {
+ setValue("");
+ onCancel?.();
+ }}
+ >
+ <CrossCircledFilledIcon />
+ </AbortButton>
}
onChange={(event) => {
setValue(event.target.value);