Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/bitter-pigs-type.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 2 additions & 0 deletions packages/ui/src/components/bible-chapter-picker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ export const LightBackground: Story = {

// Clear search and select Genesis
const currentSearchInput = overlay.getByPlaceholderText(/search/i);
// user-event cannot clear an input in a shadow root: it checks
// document.activeElement, which is the shadow host.
await fireEvent.input(currentSearchInput, { target: { value: '' } });
await waitFor(() => expect(overlay.getByText('Genesis')).toBeInTheDocument());
await userEvent.click(overlay.getByText('Genesis'));
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/bible-chapter-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ function Content({ onRequestClose, onSelect }: BibleChapterPickerContentProps) {
dir="auto"
className="yv:text-base yv:leading-normal"
value={searchQuery}
// onInput, not onChange: onChange does not update the query inside the picker's
// shadow root. The picker search stories fail with onChange.
onInput={(event) => setSearchQuery(event.currentTarget.value)}
/>
<InputGroupAddon align="inline-start">
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/components/bible-version-picker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ export const LanguageSearch: Story = {
const currentLanguageSearchInput = overlay.getByRole('textbox', {
name: /search languages/i,
});
// user-event cannot clear an input in a shadow root: it checks
// document.activeElement, which is the shadow host.
await fireEvent.input(currentLanguageSearchInput, { target: { value: '' } });
await userEvent.type(currentLanguageSearchInput, 'Koreanea', { delay: 50 });

Expand Down
4 changes: 4 additions & 0 deletions packages/ui/src/components/bible-version-picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,8 @@ function Content({ open, onRequestClose }: BibleVersionPickerContentProps = {})
placeholder={t('searchPlaceholder')}
dir="auto"
value={searchQuery}
// onInput, not onChange: onChange does not update the query inside the picker's
// shadow root. The picker search stories fail with onChange.
onInput={(event) => setSearchQuery(event.currentTarget.value)}
></InputGroupInput>
<InputGroupAddon>
Expand Down Expand Up @@ -1098,6 +1100,8 @@ export function BibleLanguagePickerContent({
placeholder={t('searchPlaceholder')}
dir="auto"
value={languageSearchQuery}
// onInput, not onChange: onChange does not update the query inside the picker's
// shadow root. The picker search stories fail with onChange.
onInput={(event) => setLanguageSearchQuery(event.currentTarget.value)}
/>
<InputGroupAddon>
Expand Down
4 changes: 4 additions & 0 deletions packages/ui/src/lib/shadow-root-host.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ async function expectStyleSheetFailureRecovery(stage: StyleSheetFailureStage): P
ownerDocument.createElement('div').attachShadow({ mode: 'open' }),
);
const adoptedStyleSheets = new WeakMap<ShadowRoot, CSSStyleSheet[]>();
const populatedStyleSheets = new WeakSet<object>();
const failedContainer = ownerDocument.createElement('div');
const recoveredContainer = ownerDocument.createElement('div');
const sharedContainer = ownerDocument.createElement('div');
Expand Down Expand Up @@ -116,6 +117,7 @@ async function expectStyleSheetFailureRecovery(stage: StyleSheetFailureStage): P
if (stage === 'replacement' && rejectFailure) {
throw new Error('replacement failed');
}
populatedStyleSheets.add(this);
}
},
});
Expand Down Expand Up @@ -157,6 +159,8 @@ async function expectStyleSheetFailureRecovery(stage: StyleSheetFailureStage): P
return root;
});
expect(recoveredRoot.adoptedStyleSheets).toHaveLength(1);
// A sheet cached before a failed replaceSync would be adopted here without SDK styles.
expect(populatedStyleSheets.has(recoveredRoot.adoptedStyleSheets[0]!)).toBe(true);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: Checking that the adopted sheet completed replacement catches the empty-sheet regression that the previous assertions missed.

For Agents: stylesheet recovery postcondition

The fake records the sheet only after replaceSync succeeds, and this assertion checks the exact adopted object's identity. Cam's review verified the failure mode in an isolated worktree: moving the cache write before replaceSync makes the replacement-recovery test fail here while the other nine tests pass.

Written by Code Reviewer bot on behalf of Cam.

expect(recoveredRoot.querySelector('style')).toBeNull();

const sharedView = render(
Expand Down
Loading