Skip to content

[Docs] Fix null-dereference, invalid DOM append, and redundant queries in hotkey.html - #1402

Merged
sarajkrishnasingh merged 3 commits into
layer5io:masterfrom
sarah-26-bit:fix/hotkey-html-cleanup
Dec 3, 2026
Merged

sarajkrishnasingh merged 3 commits into
layer5io:masterfrom
sarah-26-bit:fix/hotkey-html-cleanup

Conversation

@sarah-26-bit

@sarah-26-bit sarah-26-bit commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Notes for Reviewers

This PR fixes #1401

  • Adds a null check in focusSearchBar() to prevent a TypeError when .td-search__input is absent.
  • Removes searchElement.appendChild(searchKey), which attempted to append a child node to an <input> void element.
  • Removes automatic .focus() on DOMContentLoaded to preserve keyboard navigation and screen-reader focus.
  • Removes the empty <style> block and queries .td-search__input once instead of three times.
  • Moves the keyboard-css@1.2.4 stylesheet link from layouts/partials/hotkey.html (rendered in <footer>) into layouts/partials/head.html since .kbc-button classes are used across the navbar search button and Kanvas keyboard shortcut pages.

Signed commits

  • Yes, I signed my commits.

Summary by CodeRabbit

  • Behavior Changes
    • Clicking the search shortcut focuses the search field, which displays “Search” as its placeholder.
    • The search field no longer receives automatic focus when the page loads.
  • Style
    • Added keyboard styling support for shortcut keys.

…o-focus

Signed-off-by: sarah-26-bit <292487297+sarah-26-bit@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e1d6da19-8c63-4bce-b02a-f02e05ca8518
Commits

Reviewing files that changed from the base of the PR and between b4dea09 and 7fd5367.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The head partial now includes keyboard-css 1.2.4. The hotkey partial checks for a search input before setting its placeholder or wiring the click handler. It removes automatic focus and moving the hotkey into the input.

Changes: Search hotkey handling

Layer / File(s) Summary
Search field setup and hotkey behavior
layouts/partials/head.html, layouts/partials/hotkey.html
The head partial adds the keyboard-css stylesheet link, and the hotkey partial removes its external stylesheet link. The focus helper checks for an input before focusing it. When an input exists, DOM-ready handling sets its placeholder to "Search" and wires the #searchKey click handler. Automatic focus and moving #searchKey into the input are removed.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: leecalcote, phukon

Merge Risk: Minimal · previous review b4dea

The change fixes the possible null dereference in the search hotkey partial and removes the invalid append and the automatic focus on page load. It moves the keyboard stylesheet to the head partial. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: fixing a null dereference, an invalid DOM append, and redundant queries in hotkey.html. The raw summary and PR objectives confirm these fixes: a null guard in focusSea…
Linked Issues check Passed Issue #1401 has four coding requirements. Each is met at the reviewed head (b4dea09).

1. Null guard [#1401]: focusSearchBar(input) calls focus() only when input is truthy. The DOMContentLoaded handle…
Out of Scope Changes check Passed All changed code maps to #1401. The hotkey.html changes remove the defects and dead code that the issue lists. The head.html change (+1 line, keyboard-css link) implements the issue's stylesheet move.…
Full details: Title check

Explanation

The title names the main change: fixing a null dereference, an invalid DOM append, and redundant queries in hotkey.html. The raw summary and PR objectives confirm these fixes: a null guard in focusSearchBar(), removal of the append to the input, removal of auto-focus, and a single query for .td-search__input. The title's "[Docs]" prefix and the length (85 characters) are acceptable, though the title is long. It omits the stylesheet move, which is a secondary change.

Full details: Linked Issues check

Explanation

Issue #1401 has four coding requirements. Each is met at the reviewed head (b4dea09).

  1. Null guard [#1401]: focusSearchBar(input) calls focus() only when input is truthy. The DOMContentLoaded handler returns early when .td-search__input is absent.
  2. Invalid DOM append [#1401]: no appendChild call to the input remains in hotkey.html.
  3. Focus steal [#1401]: no automatic focus runs on DOMContentLoaded. Focus runs only inside the #searchKey click listener.
  4. Cleanup [#1401]: the empty <style> block is gone. .td-search__input is queried once. The keyboard-css@1.2.4 link moved from hotkey.html to head.html. This satisfies the issue's 'move or remove' option.

The head.html change was read directly in this assessment. It adds one stylesheet link line and no other change. The issue sets no test requirement, so no test gap applies.

Full details: Out of Scope Changes check

Explanation

All changed code maps to #1401. The hotkey.html changes remove the defects and dead code that the issue lists. The head.html change (+1 line, keyboard-css link) implements the issue's stylesheet move. The placeholder assignment is kept on the cached searchBar reference. The head.html diff shows no other changes, and no unrelated files were identified in the summary.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: eac7133c-5b9d-4d80-b31f-786eddab78ed
Commits

Reviewing files that changed from the base of the PR and between 62d99e7 and b4dea09.

Files selected for processing: 1

  • layouts/partials/hotkey.html

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@sarajkrishnasingh sarajkrishnasingh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice cleanup, and a good catch on all three bugs. The null check in focusSearchBar stops the TypeError on pages without a search input, removing the appendChild fixes an invalid DOM operation on a void input element, and dropping the automatic focus on DOMContentLoaded is the right call for keyboard and screen-reader users. Querying .td-search__input once instead of three times and moving the keyboard-css stylesheet into head.html, where it belongs now that .kbc-button is used across the navbar and Kanvas pages, tidy the partial up well.

Checks: DCO is green; CodeRabbit was still running when I reviewed. As a website-only change no code test coverage is needed.

One small tidy-up, left inline: the fallback query inside focusSearchBar is now unreachable, since the only caller always passes the element it already queried.

Comment thread layouts/partials/hotkey.html Resolved
Signed-off-by: sarah-26-bit <292487297+sarah-26-bit@users.noreply.github.com>
@sarah-26-bit

Copy link
Copy Markdown
Contributor Author

Thank you for the thorough review, @sarajkrishnasingh! Good catch on the unreachable fallback query in focusSearchBar — I've simplified the helper to accept and guard input directly in b4dea09. Ready for another look whenever you have a moment.

@sarajkrishnasingh sarajkrishnasingh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for fixing #1401, this cleans up hotkey.html nicely.

What looks good:

  • The null guard in focusSearchBar and the early return when .td-search__input is absent remove the TypeError on pages without a search input.
  • Removing the appendChild call fixes the invalid attempt to append a child to an input void element, and dropping the automatic focus on DOMContentLoaded preserves keyboard navigation and screen reader focus.
  • Querying .td-search__input once, removing the empty style block, and moving the keyboard-css stylesheet link into head.html are all sound cleanups. A stylesheet belongs in head, not in the footer partial.

Checks: DCO is green and CodeRabbit skipped with nothing to flag. No test coverage needed here since this is a docs site fix, and the change is confined to the two partials the issue names.

@sarajkrishnasingh
sarajkrishnasingh merged commit 382b004 into layer5io:master Dec 3, 2026
2 checks passed
@welcome

welcome Bot commented Dec 3, 2026

Copy link
Copy Markdown

        Thank you for contributing to the Layer5 community! 🎉 \ \ Congrats! \ \         ⭐ Please leave a star on the project. 😄

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.

[Bug] Fix null-dereference, invalid DOM append, and redundant queries in hotkey.html

2 participants