thaw icon indicating copy to clipboard operation
thaw copied to clipboard

Unescapable nested div class in AutoComplete

Open qrilka opened this issue 1 year ago • 10 comments

AutoComplete provies class for its main div but internally it uses Input which adds an extra div inside and class for that input can't be changed through AutoComplete params

qrilka avatar Feb 13 '24 14:02 qrilka

I can add an input_class parameter to the AutoComplete component.

lizidev avatar Feb 18 '24 14:02 lizidev

There's attr:class which gets applied to input, basically right now we have:

<div> - with `class` available as `class` (`thaw-auto-complet` by default)
  <div> - with hard-coded `thaw-input` class
    <input> - with class available as `attr:class`

using input_class for 2nd level div would be confusing at least

qrilka avatar Feb 18 '24 14:02 qrilka

Do you have any good ideas?

lizidev avatar Feb 18 '24 15:02 lizidev

Not right now. I think the core problem here comes from this implicit nesting of Input inside of AutoComplete: ideally we should have only one div, it looks like on:keydown and class could be moved into Input but I'm not sure about auto_complete_ref what is it used for (BTW the guide doesn't quite tell much about it)?

qrilka avatar Feb 18 '24 15:02 qrilka

One more detail: in Input there's a warning of one uses attr:class so I get in console:

Thaw: The 'class' attribute already exists on elements inside the Input component, which may cause conflicts.

basically it means that the third option (overriding input class with attr:class) isn't advised by the library at the moment.

qrilka avatar Feb 19 '24 13:02 qrilka

but I'm not sure about auto_complete_ref what is it used for

auto_complete_ref is mainly used to get the DOM position in real time to display the popup position.

Also, can you write an example of your needs?

lizidev avatar Feb 22 '24 14:02 lizidev

In my example I was trying to fit it into tailwind css classes written by another engineer. It's just a prototype so maybe we'll just throw away that piece of code soon.

qrilka avatar Feb 22 '24 15:02 qrilka

@luoxiaozero could you help me finding PR/commit which fixed this? (cross-links could be helpful for cases like this BTW)

qrilka avatar Mar 24 '24 08:03 qrilka

Sorry, I thought you no longer need this feature. I will reopen issue.

cross-links could be helpful for cases like this BTW

What does cross-links mean?

lizidev avatar Mar 28 '24 08:03 lizidev

with a cross-link I meant a link between a PR or commit and a ticket, e.g. Github finds those and adds to the ticket.

qrilka avatar Mar 28 '24 19:03 qrilka