Skip to content

Commit

Permalink
v
Browse files Browse the repository at this point in the history
  • Loading branch information
julianbenegas committed May 11, 2024
1 parent 0ecdf13 commit 08ee565
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
1 change: 1 addition & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"dull-paws-arrive",
"giant-insects-jump",
"long-roses-juggle",
"tame-yaks-decide",
"thick-balloons-repair",
"three-turkeys-grow",
"tidy-swans-deny",
Expand Down
5 changes: 5 additions & 0 deletions .changeset/tame-yaks-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"basehub": patch
---

nits
6 changes: 6 additions & 0 deletions packages/basehub/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# basehub

## 4.0.16-canary.11

### Patch Changes

- nits

## 4.0.16-canary.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/basehub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "basehub",
"description": "The first AI-native content hub.",
"author": "JB <[email protected]>",
"version": "4.0.16-canary.10",
"version": "4.0.16-canary.11",
"license": "MIT",
"repository": "basehub-ai/basehub",
"bugs": "https://github.com/basehub-ai/basehub/issues",
Expand Down
19 changes: 15 additions & 4 deletions packages/basehub/src/react/search/primitive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ const Root = <

// reset selected index when recent searches are in display (query is empty)
React.useEffect(() => {
if (!search.recentSearches || search.query) return;
if (!search.recentSearches?.hits || search.query) return;
setSelectedIndex(0);
handleSelectedNodeDOMMutationsOnIndexChange({
orderedNodes: undefined,
Expand All @@ -541,7 +541,7 @@ const Root = <
}, [
handleSelectedNodeDOMMutationsOnIndexChange,
search.query,
search.recentSearches,
search.recentSearches?.hits,
]);

if (search.valid === false) return null;
Expand Down Expand Up @@ -736,8 +736,8 @@ const HitItem = React.forwardRef<
},
"ref"
>
>(({ asChild, hit, onClick, ...props }, ref) => {
const { id, recentSearches } = useContext();
>(({ asChild, hit, onClick, onFocus, ...props }, ref) => {
const { id, recentSearches, onIndexChange } = useContext();
const Comp = asChild ? Slot : "a";

return (
Expand All @@ -753,6 +753,17 @@ const HitItem = React.forwardRef<
recentSearches.add(hit);
}
}}
onFocus={(e) => {
onFocus?.(e as React.FocusEvent<HTMLAnchorElement>);
const orderedNodes = Array.from(
document.querySelectorAll<HTMLElement>(
`[data-basehub-hit-for="${id}"]`
)
);
const index = orderedNodes.indexOf(e.currentTarget);
if (index === -1) return;
onIndexChange({ type: "set", value: index });
}}
/>
</HitContext.Provider>
);
Expand Down
7 changes: 7 additions & 0 deletions playground/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# playground

## 0.0.86-canary.11

### Patch Changes

- Updated dependencies
- [email protected]

## 0.0.86-canary.10

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "playground",
"private": true,
"version": "0.0.86-canary.10",
"version": "0.0.86-canary.11",
"scripts": {
"dev": "basehub dev & next dev",
"build": "next build",
Expand Down

0 comments on commit 08ee565

Please sign in to comment.