Skip to content

[BUG] - Input inside Dropdown as DropdownItem doesn't recognize whitespaces #5256

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

Open
Vishvsalvi opened this issue Apr 30, 2025 · 3 comments
Assignees

Comments

@Vishvsalvi
Copy link
Contributor

HeroUI Version

2.7.8

Describe the bug

When you use Input inside DropdownItem, hit spacebar, the whitespace is not accepted.

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

Use this code to reproduce the issue

"use client"
import {Dropdown, DropdownTrigger, DropdownMenu, DropdownItem, Button, Input, Card} from "@heroui/react";  
import { useState, useEffect, useRef } from "react";

export default function App() {
    const [isOpen, setIsOpen] = useState(false);
    const [submitted, setSubmitted] = useState(false);
    const [value, setValue] = useState("")
    const inputRef = useRef<HTMLInputElement>(null);
    useEffect(() => {
        if (isOpen && !submitted && inputRef.current) {
          setTimeout(() => {
            inputRef.current?.focus();
          }, 100);
        }
      }, [isOpen, submitted]);

  return (
    <Dropdown
    isOpen={isOpen} 
    onOpenChange={setIsOpen}
    closeOnSelect={false}
    >
      <DropdownTrigger>
        <Button variant="bordered">Open Menu</Button>
      </DropdownTrigger>
      <DropdownMenu aria-label="Static Actions">
        <DropdownItem key="new">New file</DropdownItem>
        <DropdownItem key="copy">
      <Input
         className="w-full text-sm"
         variant="bordered"
         placeholder="Precio máximo"
         type="text"
         value={value}
         description="Enter your name"
         onChange={(e) => setValue(e.target.value)}
         ref={inputRef}
         />
         
        </DropdownItem>
        <DropdownItem key="edit">Edit file</DropdownItem>
        <DropdownItem key="delete" className="text-danger" color="danger">
          Delete file
        </DropdownItem>
      </DropdownMenu>
    </Dropdown>
  );
}

Expected behavior

I expect normal Input behaviour which recognize whitespaces

Screenshots or Videos

Image

Operating System Version

Windows

Browser

Chrome

Copy link

linear bot commented Apr 30, 2025

@Vishvsalvi
Copy link
Contributor Author

@wingkwong please assign this to me if no one is considering working on it

@Vishvsalvi
Copy link
Contributor Author

@wingkwong this issue persist in the React Aria library's ListBoxItem component which I believe is used build HeroUI's DropdownItem, MenuItem.

I implemented a simple editable div and normal html input inside React Aria's ListBoxItem, it displayed same bug. HeroUI's Input component has no bugs

<ListBox>
  <ListBoxItem>
   <div
      ref={divRef}
      contentEditable={isEditable}
      onDoubleClick={handleDoubleClick}
      onBlur={handleBlur}
      style={{
        border: '1px solid #ccc',
        padding: '10px',
        width: '300px',
        minHeight: '50px',
        cursor: 'pointer',
      }}
      suppressContentEditableWarning={true}
    >
      Double-click to edit this text.
    </div>
  </ListBoxItem>

  <ListBoxItem>
<input type="text" />
  </ListBoxItem>
  <ListBoxSection>
    <Header />
    <ListBoxItem />
  </ListBoxSection>
</ListBox>

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

No branches or pull requests

1 participant