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

field outlines are hidden - even when focus is applied. #489

Closed
rubys opened this issue Feb 3, 2025 · 2 comments · Fixed by #490
Closed

field outlines are hidden - even when focus is applied. #489

rubys opened this issue Feb 3, 2025 · 2 comments · Fixed by #490

Comments

@rubys
Copy link
Contributor

rubys commented Feb 3, 2025

A typical form field looks like the following:

    <%= form.textarea :address, rows: 4, class: ["block shadow-sm rounded-md border outline-hidden px-3 py-2 mt-2 w-full",
                    {"border-gray-400 focus:outline-blue-600": order.errors[:address].none?,
                    "border-red-400 focus:outline-red-600": order.errors[:address].any?}] %>

Key items:

  • outline-hidden
  • focus:outline-blue-600
  • focus:outline-red-600

Missing is a focus outline-style something like solid, dashed, dotted, or double. Not knowing the intent here, I'm hesitant to provide a PR.

@patriciomacadden
Copy link
Contributor

The intent, correct me if I'm wrong, is to show a blue outline when the field is focused and a red one when there is an error. Before the v4 upgrade, outline-hidden was actually outline-none (see #464) and even though they are defined the same, the current set of classes no longer work that way.

Both outline-hidden (v4) and outline-none (v3) are defined as:

outline: 2px solid transparent;
outline-offset: 2px;

however, in v4, it's compiled as:

.outline-hidden {
  outline-style: none;
}
@media (forced-colors:active) {
  .outline-hidden {
    outline-offset: 2px;
    outline: 2px solid #0000;
  }
}

meaning that the solid outline is set when the forced-colors media feature is set. If you want to try out, you can turn forced-colors: active in your dev tools (it doesn't look right either).

So indeed, it would be nice to have a focus:outline-solid class (and maybe remove outline-hidden).

rubys added a commit to rubys/tailwindcss-rails that referenced this issue Feb 4, 2025
@rubys
Copy link
Contributor Author

rubys commented Feb 4, 2025

Reproduction instructions (adapted from Getting Started with Rails):

rails new store --css tailwind
cd store
bin/rails generate scaffold Product name:string
bin/rails db:migrate
sed -i.bak '/end/i\
  validates :name, presence: true
' app/models/product.rb
bin/dev

Navigate to http://localhost:3000/products/new ; click on the input field; then click on Create Products and finally on the input field again.

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 a pull request may close this issue.

2 participants