Skip to content

Masthead: default element for MastheadBrand #4665

@mcoker

Description

@mcoker

patternfly/patternfly#3332

My thought would be to only make the logo an a tag if there's an href. In this context an <a> tag without an href doesn't make much sense.

Referencing the PageHeader component - since logoComponent is an a by default, it needs some sort of link attribute for that to be the appropriate element to use there. I wonder if there is a good way to detect whether the element is suitable as an <a> or some other element? As in if it has an href or sets a location on click, it's rendered as an <a>? If it just has a click handler, maybe it should be a <button> instead, or role="button", since an <a> without a href has no implicit role. Otherwise it's rendered as a <span>?

I see you can pass a logoComponent to achieve these variations, but was curious if there is a way we could do this detection for the user and default to a <span>

UPDATE: The PageHeader and it's logoComponent prop are deprecated in v5. But we would want to make this same change to the MastheadBrand component, so that it's only an anchor when an href is provided, otherwise it'd default to a div (and can be overriden by MastheadBrand's component prop)

Metadata

Metadata

Assignees

Labels

Breaking change 💥this change requires a major release and has API changes.PF5

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions