Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove invalid nested <button> inside <a> element in heex templates #5814

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

phoebe100
Copy link
Contributor

Fixes #5770

@@ -1,8 +1,8 @@
<.header>
Listing <%= schema.human_plural %>
<:actions>
<.link href={~p"<%= schema.route_prefix %>/new"}>
<.button>New <%= schema.human_singular %></.button>
<.link href={~p"<%= schema.route_prefix %>/new"} class="py-2 px-3 text-sm font-semibold rounded-lg bg-zinc-100 hover:bg-zinc-200/80">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suggest this style since a very similar style is already used for the button-alike link "Get Started" in app.html.heex

Copy link
Member

Choose a reason for hiding this comment

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

We should avoid using tailwind styles in generators. The home page is fine, because we discard it. Could we use <.button> only instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

In my projects I have a <.button link={%{patch: ...}} that then has a properly styled <.link inside. Maybe that's the way to go?

Copy link
Contributor Author

@phoebe100 phoebe100 May 21, 2024

Choose a reason for hiding this comment

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

What about plain old link by simply using <.link> without any fancy style?
Buttons would always require javascript and some users might create their projects with --no-live flag.

Or the generators could produce different elements:

  • mix phx.gen.live could use <.button> with phx-click only
  • while mix phx.gen.html could stick to simple <.link> (which could still be styled/replaced further if CoreComponents gets some button-alike link component in the future)

SteffenDE added a commit that referenced this pull request May 21, 2024
Nesting a button inside an anchor tag is not valid HTML. This change
introduces a new `link` attribute in the `button` core component that,
when present, will render the button as an anchor tag instead.

Fixes #5770.
References #5814.
SteffenDE added a commit that referenced this pull request May 21, 2024
Nesting a button inside an anchor tag is not valid HTML. This change
introduces a new `link` attribute in the `button` core component that,
when present, will render the button as an anchor tag instead.

Fixes #5770.
References #5814.
SteffenDE added a commit that referenced this pull request May 21, 2024
Nesting a button inside an anchor tag is not valid HTML. This change
introduces a new `link` attribute in the `button` core component that,
when present, will render the button as an anchor tag instead.

Fixes #5770.
References #5814.
SteffenDE added a commit that referenced this pull request May 21, 2024
Nesting a button inside an anchor tag is not valid HTML. This change
introduces a new `link` attribute in the `button` core component that,
when present, will render the button as an anchor tag instead.

Fixes #5770.
References #5814.
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.

HTML and Live CRUD generators output invalid HTML (buttons nested in links)
3 participants