Skip to content

Commit 4c86827

Browse files
authored
fix: select input text for oneof dropdown on focus (#675)
This makes it easier for users to "search" for an item as soon as they click on the dropdown.
1 parent 840e252 commit 4c86827

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

.changeset/shiny-cherries-guess.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@blinkk/root-cms': patch
3+
---
4+
5+
fix: select input text for oneof dropdown on focus (#675)

packages/root-cms/ui/components/DocEditor/DocEditor.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,6 +1310,15 @@ DocEditor.OneOfField = (props: FieldProps) => {
13101310
return unsubscribe;
13111311
}, [props.draft, props.deepKey]);
13121312

1313+
// When the dropdown receives focus, highlight the <input> text so that it can
1314+
// be easily searched.
1315+
function onDropdownFocus(e: FocusEvent) {
1316+
const target = e.target as HTMLInputElement;
1317+
if (target && target.select) {
1318+
target.select();
1319+
}
1320+
}
1321+
13131322
return (
13141323
<div className="DocEditor__OneOfField">
13151324
<div className="DocEditor__OneOfField__select">
@@ -1319,6 +1328,7 @@ DocEditor.OneOfField = (props: FieldProps) => {
13191328
value={type}
13201329
placeholder={field.placeholder}
13211330
onChange={(e: string) => onTypeChange(e || '')}
1331+
onFocus={onDropdownFocus}
13221332
size="xs"
13231333
radius={0}
13241334
searchable

0 commit comments

Comments
 (0)