Skip to content

fix: Let navbar_item accept target - #183

Open
grahac wants to merge 1 commit into
elixir-error-tracker:mainfrom
grahac:fix/navbar-item-target-attrs
Open

grahac wants to merge 1 commit into
elixir-error-tracker:mainfrom
grahac:fix/navbar-item-target-attrs

Conversation

@grahac

@grahac grahac commented Sep 29, 2026

Copy link
Copy Markdown

Every compile on Elixir 1.20 warns about the navbar's own link:

warning: undefined attribute "target" for component ErrorTracker.Web.Layouts.navbar_item/1

The attribute is not only warned about, it is dropped. target is not one of Phoenix's
global attributes (@globals in phoenix_live_view/lib/phoenix_component/declarative.ex
has tabindex, title, and friends), so target="_blank" never makes it into @rest —
the attribute the <a> interpolates — and the GitHub link opens in the same tab.

include: ~w(target) adds it to the global set, which is the documented way to extend
attr :rest, :global. The attribute renders and the warning goes away.

Found while pinning a fork of 0.9.0 for a downstream app on Elixir 1.20.2 /
phoenix_live_view 1.2.12. Related to #175.

navbar_item/1 declares attr :rest, :global, but target is not one of
Phoenix's global attributes, so the target="_blank" the navbar passes to it
was dropped at render time -- and Elixir 1.20 warned about it on every
compile:

    warning: undefined attribute "target" for component
    ErrorTracker.Web.Layouts.navbar_item/1

Adding target to the global include list puts it into @rest, the attribute
the <a> interpolates, so it renders and the warning goes away.
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