Skip to content

Navigation Component: What to Search and How #25509

@Copons

Description

@Copons

This issue depends on #25252, and was spurred by a discussion happened in #25315 (#25315 (comment) and following comments).

The plan (WIP in #25315) is to make Navigation searchable: typing into a search field would filter the items, keeping only those items that contain the search query.

Normally, NavigationItem is used with a title prop (rendered as item label), so it's just obvious to search on that.

But NavigationItem can also render a custom component, which makes the title not mandatory (and not rendered anyway).
We could search into the custom component's text content, although it could be expensive performance-wise on large navigation lists: for example, we might need to store its ref, or recursively traverse its DOM.

Possibilities to discuss:

  • Require title for custom component items, even if it's not rendered.

    • Pros: easy to develop and to consume.
    • Cons: counterintuitive to use; inconsistent for the end user if title and content don't match.
  • Add a new keywords prop, to be used simlarly to Blocks keywords. We could search on those if no title is provided, or even in addition to it.

    • Pros: precise search results.
    • Cons: yet another thing the consumer will need to remember; inconsistent for the end user if keywords and content don't match.
  • Store the custom component ref and search into Node.textContent().

    • Pros: easy to develop; consumers wouldn't need to do anything.
    • Cons: possibly bad performances; wouldn't work for custom components without text (e.g. images, icons).
  • Traverse recursively through the custom component children.

    • Pros: consumer wouldn't need to do anything; we might customize the traversal to pick up non-text content (e.g. alt attributes).
    • Cons: possibly bad performances.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions