Skip to content

Fix for contents menu items#950

Open
eomerdws wants to merge 3 commits intosillsdev:mainfrom
eomerdws:fix-contents-menu
Open

Fix for contents menu items#950
eomerdws wants to merge 3 commits intosillsdev:mainfrom
eomerdws:fix-contents-menu

Conversation

@eomerdws
Copy link
Contributor

@eomerdws eomerdws commented Mar 20, 2026

  1. Context menu items that David M. found that were broken are now fixed because of an incorrect order of div tags
  2. Found an additional issue if an HTMLElement instead of an Element is passed through parseItemTags and parseItemLinks the Object.keys(tag).length === 0 failed to check properly. Apparently there is some weirdness with DOM versions that this works sometimes and other times fails. I removed it. It was simply to save processing power and time when the object was empty.

Summary by CodeRabbit

  • Refactor

    • Improved handling of empty or unexpected content tags to make content parsing more robust.
    • Reorganized content-item layout so media (audio/image) and text are grouped in a horizontal block for more consistent rendering.
  • Tests

    • Adjusted content link validation tests to align with the updated parsing behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 20, 2026

📝 Walkthrough

Walkthrough

Removed empty-object guards from XML parsing helpers so they operate when tag is defined, and restructured the contents item DOM to nest audio, image, and text blocks inside a new .contents-layout-horizontal wrapper.

Changes

Cohort / File(s) Summary
Parsing Logic
convert/convertContents.ts
Removed Object.keys(tag).length === 0 checks from parseItemLink, parseItemFeatures, and parseItemLayoutMode; functions now call getElementsByTagName / query layout when tag is defined, with an optional verbose warning in parseItemLink if getElementsByTagName is missing.
DOM Structure
src/routes/contents/[id]/+page.svelte
Wrapped item.audioFilename, item.imageFilename, and the .contents-text-block (title, subtitle, async reference) inside a new .contents-layout-horizontal container — preserves conditions, async logic, and handlers but changes DOM nesting.
Tests
convert/tests/sab/convertContentSAB.test.ts
Removed/commented an assertion that link.linkTarget is not undefined in a link-type validation test; other conditional validations remain guarded by !== undefined.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • chrisvire

Poem

🐰 I nudged a guard out of the way,

now tags may frolic, come what may.
Audio, image, text in a row,
snug in a horizontal flow.
Hop, click, and the content will play. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix for contents menu items' directly relates to the main changes: fixing a DOM structure issue in the contents menu rendering and removing problematic Object.keys checks in parsing functions.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can enforce grammar and style rules using `languagetool`.

Configure the reviews.tools.languagetool setting to enable/disable rules and categories. Refer to the LanguageTool Community to learn more.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@convert/tests/sab/convertContentSAB.test.ts`:
- Line 480: Re-enable the strict assertion
expect(link.linkTarget).not.toBeUndefined() in the test and ensure the parser
enforces that typed links (e.g., reference/screen) must have a target by
updating parseItemLink to validate the parsed tag contents: if a tag indicates a
typed link but has no target (previously bypassed when Object.keys(tag).length
=== 0 was removed), treat it as invalid (return null/throw or mark link as
invalid) so the test fails as intended; reference parseItemLink and the
link.linkTarget property to locate and change the behavior and then restore the
commented assertion in the test.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9d06922f-be0b-4533-af6b-923b6870354b

📥 Commits

Reviewing files that changed from the base of the PR and between 94a5d5b and 5aa67cb.

📒 Files selected for processing (2)
  • convert/convertContents.ts
  • convert/tests/sab/convertContentSAB.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • convert/convertContents.ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant