APB9785

APB9785

Creator of ECSx

Why is the cursor/caret in my text_input missing when empty?

I have a simple form with one input, which is shown upon change to @add_category

<%= if @add_category do %>
  <div class="flex">
    <%= f = form_for @category_changeset, "#", phx_submit: "save_category" %>
      <%= text_input f, :name, class: "border border-gray-700", phx_hook: "AutoFocus", autocomplete: "off" %>
      <%= error_tag f, :name %>
      <%= submit "Create category" %>
    </form>
  </div>

But when the text_input is focused, the blinking cursor (aka caret) does not appear. After some text is entered, it does appear and blink as usual. But if I remove the text and make the input empty again, the cursor disappears. So far, I’ve tried adding placeholders, default values, turning off autocomplete, adding classes such as appearance-none, using standard <input></input> instead of the helper, but nothing has properly enabled the cursor when the input is empty. I’ve also tried several other web browsers, without any luck.

Does anyone know what the problem is here?

Marked As Solved

APB9785

APB9785

Creator of ECSx

For anyone else experiencing this issue, here is a solution that worked for me:

<%= text_input f, :name, class: "pl-1" %>

which is the tailwind equivalent of padding-left: 0.25rem;

It seems like the cursor/caret was overlapping the left border of the input field, and adding this small amount of padding moves it just far enough to be seen.

Nothing to do with Phoenix. Just basic HTML/CSS troubles :smile:

Also Liked

APB9785

APB9785

Creator of ECSx

I use vanilla Brave, mostly.

Where Next?

Popular in Questions Top

chokchit
** (DBConnection.ConnectionError) connection not available and request was dropped from queue after 2733ms. You can configure how long re...
New
hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a &gt; b) do {:ok, "a"} end if (a &lt; b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43806 214
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New

We're in Beta

About us Mission Statement