Skip to content

Commit

Permalink
feat(listbox-popover): Tab stop for search (#1097)
Browse files Browse the repository at this point in the history
* test: utils covered

* fix: listbox selection dropdown anchor ref

* feat: search tab stop for listbox popover

* fix: optional auto focus for search field

* fix: broken test

* feat: change to `autoFocus`

* fix: default autofocus to true in listbox popover

* fix: broken rendering tests
  • Loading branch information
a-m-dev committed Mar 7, 2023
1 parent 45341be commit a65e7a1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 9 additions & 1 deletion apis/nucleus/src/components/listbox/ListBoxPopover.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default function ListBoxPopover({
app,
fieldName,
stateName = '$',
autoFocus,
}) {
const isMasterDim = Boolean(fieldName?.qLibraryId);
const open = show && Boolean(alignTo.current);
Expand Down Expand Up @@ -167,7 +168,14 @@ export default function ListBoxPopover({
</Grid>
<Grid item xs>
<div ref={moreAlignTo} />
<ListBoxSearch selections={selections} model={model} listCount={listCount} visible />
<ListBoxSearch
visible
model={model}
listCount={listCount}
selections={selections}
keyboard={{ enabled: false }}
autoFocus={autoFocus ?? true}
/>
<ListBox model={model} selections={selections} direction="ltr" onSetListCount={(c) => setListCount(c)} />
</Grid>
</Grid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export default function ListBoxPopoverWrapper({ app, fieldIdentifier, stateName,
close={handleCloseShowState}
fieldName={fieldIdentifier}
stateName={stateName}
autoFocus={options.autoFocus}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function ListBoxSearch({
keyboard,
dense = false,
visible = true,
autoFocus = true,
wildCardSearch = false,
searchEnabled,
}) {
Expand Down Expand Up @@ -161,10 +162,10 @@ export default function ListBoxSearch({
fullWidth
placeholder={translator.get('Listbox.Search')}
value={value}
autoFocus
onFocus={handleFocus}
onChange={onChange}
onKeyDown={onKeyDown}
autoFocus={autoFocus}
inputProps={{
tabIndex: keyboard && (!keyboard.enabled || keyboard.active) ? 0 : -1,
}}
Expand Down

0 comments on commit a65e7a1

Please sign in to comment.