Skip to content

Commit

Permalink
selectOnFocus
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnCh committed Sep 23, 2024
1 parent 66af1b7 commit 749d665
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/SuperDrawer/components/SuperDrawerHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface SuperDrawerHeaderProps {
}

interface SuperDrawerHeaderStructuredProps {
title: string;
title: string | ReactNode;
left?: ReactNode;
right?: ReactNode;
hideControls?: boolean;
Expand All @@ -32,7 +32,7 @@ export function SuperDrawerHeader(props: SuperDrawerHeaderProps | SuperDrawerHea
{isStructuredProps(props) ? (
<div css={Css.df.jcsb.aic.gap2.fg1.$}>
<div css={Css.fg1.df.aic.gap2.$}>
<h1>{props.title}</h1>
{typeof props.title === "string" ? <h1>{props.title}</h1> : props.title}
{props.left}
</div>
{props.right && <div css={Css.fs0.$}>{props.right}</div>}
Expand Down
4 changes: 3 additions & 1 deletion src/inputs/TextFieldBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export interface TextFieldBaseProps<X>
// Replaces empty input field and placeholder with node
// IE: Multiselect renders list of selected items in the input field
unfocusedPlaceholder?: ReactNode;
selectOnFocus?: boolean;
}

// Used by both TextField and TextArea
Expand Down Expand Up @@ -97,6 +98,7 @@ export function TextFieldBase<X extends Only<TextFieldXss, X>>(props: TextFieldB
alwaysShowHelperText = false,
fullWidth = fieldProps?.fullWidth ?? false,
unfocusedPlaceholder,
selectOnFocus = true,
} = props;

const typeScale = fieldProps?.typeScale ?? (inputProps.readOnly && labelStyle !== "hidden" ? "smMd" : "sm");
Expand Down Expand Up @@ -188,7 +190,7 @@ export function TextFieldBase<X extends Only<TextFieldXss, X>>(props: TextFieldB
}

const onFocusChained = chain((e: FocusEvent<HTMLInputElement> | FocusEvent<HTMLTextAreaElement>) => {
e.target.select();
if (selectOnFocus) e.target.select();
}, onFocus);

// Simulate clicking `ElementType` when using an unfocused placeholder
Expand Down

0 comments on commit 749d665

Please sign in to comment.