Skip to content

Conversation

@colton-demetriou
Copy link
Contributor

Screenshot 2025-11-10 at 5 56 50 PM

Also added empty slot state for header links

@github-actions
Copy link
Contributor

Warning: Component files have been updated but no migrations have been added. See https://github.com/yext/visual-editor/blob/main/packages/visual-editor/src/components/migrations/README.md for more information.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 10, 2025

Walkthrough

Adds a new top-level localization key secondaryHeaderHiddenOnLivePage across many visual-editor locale JSON files. Updates two UI components: SecondaryHeaderSlot now uses the translation and explicitly renders a dashed placeholder when editing and the header is hidden (otherwise nothing or the regular PageSection), and HeaderLinks filters out links without a target, bases rendering and overflow logic on that filtered list, and shows an editable draggable placeholder when no valid links exist.

Sequence Diagram(s)

sequenceDiagram
    participant EditorUI as Editor UI
    participant SecondaryHeader as SecondaryHeaderSlot
    participant I18n as Translations
    rect `#EDF7ED`
    EditorUI->>SecondaryHeader: render(show, editing)
    SecondaryHeader->>I18n: lookup("secondaryHeaderHiddenOnLivePage")
    note right of I18n: translation returned
    end
    alt editing && show == false
        SecondaryHeader->>EditorUI: render dashed placeholder with translated label
    else show == false
        SecondaryHeader->>EditorUI: render nothing
    else
        SecondaryHeader->>EditorUI: render PageSection (LinksSlot, LanguageDropdown)
    end
Loading
sequenceDiagram
    participant Header as HeaderLinks
    participant Data as props.data.links
    participant Render as Renderer

    Header->>Data: receive links array
    Header->>Header: filter validLinks (link truthy)
    alt validLinks.length == 0
        Header->>Render: if editing -> render draggable placeholder navigation
        Header->>Render: if not editing -> render empty
    else
        Header->>Render: render main list from validLinks
        Header->>Render: render overflow dropdown from validLinks (based on threshold)
    end
Loading

Suggested labels

create-dev-release

Suggested reviewers

  • mkilpatrick
  • briantstephan
  • asanehisa

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: empty secondary header state' accurately describes the main change—adding an empty state for the secondary header component, which is the primary focus across all modified locale files and component changes.
Description check ✅ Passed The description mentions adding an empty secondary header state and an empty slot state for header links, both of which are present in the changeset. The visual screenshot provides additional context for the changes.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch header-empty

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13493ea and 5bf30d9.

📒 Files selected for processing (1)
  • packages/visual-editor/src/components/header/HeaderLinks.tsx (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: call_unit_test / unit_tests (20.x)
  • GitHub Check: call_unit_test / unit_tests (18.x)
  • GitHub Check: semgrep/ci
🔇 Additional comments (4)
packages/visual-editor/src/components/header/HeaderLinks.tsx (4)

76-76: LGTM: Removed unused t destructuring.

The component now consistently uses pt() for label resolution throughout, so removing t from the destructuring is correct.


101-102: LGTM: Centralized link validation.

Filtering links without targets is the right approach—it prevents rendering broken links and centralizes the validation logic. The optional chaining and fallback handle edge cases correctly.


103-122: LGTM: Empty state handling is well-implemented.

The editing-mode placeholder provides good UX by maintaining the component's presence and size, while the live-mode empty fragment correctly hides the component when there's nothing to show. The structure properly mirrors the populated state.


124-169: LGTM: Main render logic correctly updated.

The refactor to use validLinks throughout is clean and consistent. The overflow logic correctly uses the filtered list length for both conditional rendering and slicing, and the index adjustments for dropdown items are accurate.


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

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: 0

🧹 Nitpick comments (1)
packages/visual-editor/locales/pt/visual-editor.json (1)

597-601: Structural inconsistency: Consider aligning secondaryHeader pattern with secondaryFooter.

The new secondaryHeaderHiddenOnLivePage key at line 601 uses a flat structure, while the existing secondaryFooter at lines 597–599 uses a nested object pattern for its hidden state. This inconsistency may create confusion for maintainers and future locale updates.

Consider restructuring to match the secondaryFooter pattern:

  "secondaryFooter": {
    "hiddenOnLivePage": "Rodapé secundário (oculto na página ao vivo)"
  },
-  "secondaryHeader": "Cabeçalho secundário",
-  "secondaryHeaderHiddenOnLivePage": "Cabeçalho secundário (oculto na página ao vivo)",
+  "secondaryHeader": {
+    "default": "Cabeçalho secundário",
+    "hiddenOnLivePage": "Cabeçalho secundário (oculto na página ao vivo)"
+  },

Alternatively, if the flat structure is intentional (e.g., due to component code using t("secondaryHeaderHiddenOnLivePage")), consider refactoring secondaryFooter for consistency.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49c524e and bb474e3.

📒 Files selected for processing (27)
  • packages/visual-editor/locales/cs/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/da/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/de/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/en-GB/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/en/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/es/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/et/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/fi/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/fr/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/hr/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/hu/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/it/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/ja/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/lt/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/lv/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/nb/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/nl/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/pl/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/pt/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/ro/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/sk/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/sv/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/tr/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/zh-TW/visual-editor.json (1 hunks)
  • packages/visual-editor/locales/zh/visual-editor.json (1 hunks)
  • packages/visual-editor/src/components/header/HeaderLinks.tsx (2 hunks)
  • packages/visual-editor/src/components/header/SecondaryHeaderSlot.tsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
packages/visual-editor/src/components/header/SecondaryHeaderSlot.tsx (1)
packages/visual-editor/src/components/header/languageDropdown.tsx (1)
  • parseDocumentForLanguageDropdown (212-280)
packages/visual-editor/src/components/header/HeaderLinks.tsx (1)
packages/visual-editor/src/components/atoms/dropdown.tsx (1)
  • DropdownMenuItem (79-79)
🔇 Additional comments (22)
packages/visual-editor/locales/cs/visual-editor.json (1)

602-602: Localization key correctly added and positioned.

The new secondaryHeaderHiddenOnLivePage key is properly placed in alphabetical order between secondaryHeader and secondaryHeaderLinks, with valid JSON syntax and appropriate Czech translation.

packages/visual-editor/locales/sv/visual-editor.json (1)

602-602: Localization entry follows established patterns and is properly integrated.

The new secondaryHeaderHiddenOnLivePage key follows the naming convention of similar hidden-state translations (e.g., secondaryFooter.hiddenOnLivePage), and the Swedish translation is linguistically consistent with existing patterns in the file. JSON syntax is valid and the key is logically placed among related secondary header translations.

Please verify that:

  1. This key is correctly referenced in SecondaryHeaderSlot.tsx or the component handling the hidden state
  2. Consistent entries have been added to all 23 language locales mentioned in the PR summary
packages/visual-editor/locales/de/visual-editor.json (1)

600-600: LGTM!

The new localization entry is properly formatted with correct JSON syntax, follows alphabetical ordering conventions, and uses consistent German phrasing that aligns with the pattern established by similar entries (e.g., secondaryFooter.hiddenOnLivePage on line 597).

packages/visual-editor/locales/sk/visual-editor.json (1)

602-602: Localization key addition looks good.

The new secondaryHeaderHiddenOnLivePage key is properly formatted, follows camelCase naming conventions, logically grouped with related secondary header translations, and the Slovak translation appears accurate. The placement between secondaryHeader and secondaryHeaderLinks maintains good key organization.

packages/visual-editor/locales/pl/visual-editor.json (1)

602-602: Localization key added correctly.

The new secondaryHeaderHiddenOnLivePage key is properly positioned between secondaryHeader and secondaryHeaderLinks, with a contextually appropriate Polish translation.

packages/visual-editor/locales/nb/visual-editor.json (1)

601-601: Localization key added correctly.

The new secondaryHeaderHiddenOnLivePage key is properly positioned with appropriate Norwegian Bokmål translation.

packages/visual-editor/locales/fr/visual-editor.json (1)

600-600: Localization key added correctly.

The new secondaryHeaderHiddenOnLivePage key is properly positioned with appropriate French translation.

packages/visual-editor/locales/en/visual-editor.json (1)

600-600: Localization key added correctly.

The new secondaryHeaderHiddenOnLivePage key is properly positioned with the English default text "Secondary Header (Hidden on live page)", which serves as the fallback for other locales.

packages/visual-editor/locales/da/visual-editor.json (1)

602-602: Localization key added correctly.

The new secondaryHeaderHiddenOnLivePage key is properly positioned with appropriate Danish translation.

packages/visual-editor/locales/lv/visual-editor.json (1)

601-601: Localization key added correctly.

The new secondaryHeaderHiddenOnLivePage key is properly positioned with appropriate Latvian translation.

packages/visual-editor/locales/et/visual-editor.json (1)

601-601: Localization key added correctly.

The new secondaryHeaderHiddenOnLivePage key is properly positioned with appropriate Estonian translation.

packages/visual-editor/locales/ro/visual-editor.json (1)

601-601: Localization key added correctly.

The new secondaryHeaderHiddenOnLivePage key is properly positioned with appropriate Romanian translation.

packages/visual-editor/locales/zh/visual-editor.json (1)

601-601: LGTM! Translation key addition is correct.

The new secondaryHeaderHiddenOnLivePage translation key is properly placed and aligns with the usage in SecondaryHeaderSlot.tsx.

packages/visual-editor/src/components/header/HeaderLinks.tsx (3)

101-101: Solid filtering logic for valid links.

The filter correctly identifies links with a truthy link property. The optional chaining ensures safety even if items are null/undefined.


103-123: Good empty state handling for the editing experience.

The placeholder provides a clear visual indication in edit mode when no valid links exist, while returning an empty fragment in non-editing mode. The use of puck.dragRef enables proper drag-and-drop functionality.


125-170: Consistent use of validLinks throughout rendering logic.

All rendering paths (main list, overflow check, dropdown items) now correctly reference validLinks instead of the raw data.links. The overflow logic properly checks validLinks.length > MAX_VISIBLE and the dropdown correctly slices from MAX_VISIBLE onwards.

packages/visual-editor/locales/hr/visual-editor.json (1)

601-601: LGTM! Translation key addition is correct.

The Croatian translation for the secondary header hidden state is properly added.

packages/visual-editor/locales/fi/visual-editor.json (1)

601-601: LGTM! Translation key addition is correct.

The Finnish translation for the secondary header hidden state is properly added.

packages/visual-editor/locales/zh-TW/visual-editor.json (1)

601-601: LGTM! Translation key addition is correct.

The Traditional Chinese translation for the secondary header hidden state is properly added.

packages/visual-editor/src/components/header/SecondaryHeaderSlot.tsx (3)

11-11: Good addition of i18n support.

The import and usage of useTranslation enables localized labels for the hidden state placeholder.

Also applies to: 94-94


103-121: Excellent conditional rendering logic for editing vs. live modes.

The logic correctly handles three states:

  • Editing + hidden: Shows a dashed placeholder with translated text, enabling drag-and-drop via dragRef
  • Non-editing + hidden: Returns empty fragment (hidden on live page)
  • Show enabled: Renders the full section (handled below)

The placeholder styling clearly indicates the hidden state while maintaining editability.


123-136: Proper rendering of visible secondary header with drag support.

When show is true, the PageSection correctly renders with:

  • dragRef for editor drag-and-drop
  • Inherited maxWidth from parent styles
  • Background and padding styles
  • Child slots for links and language dropdown

benlife5
benlife5 previously approved these changes Nov 11, 2025
@colton-demetriou colton-demetriou merged commit 6f8f7e9 into fall-2025-slot-ify-components Nov 11, 2025
15 checks passed
@colton-demetriou colton-demetriou deleted the header-empty branch November 11, 2025 20:13
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.

3 participants