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

PanelMenu: InputText not working correctly #6413

Closed
Usamacs66 opened this issue Apr 17, 2024 · 3 comments
Closed

PanelMenu: InputText not working correctly #6413

Usamacs66 opened this issue Apr 17, 2024 · 3 comments
Labels
Resolution: Invalid Issue or pull request is not valid in the latest version

Comments

@Usamacs66
Copy link

Describe the bug

import React from 'react';
import { PanelMenu } from 'primereact/panelmenu';
import { MenuItem } from 'primereact/menuitem';
import { Badge } from 'primereact/badge';

export default function TemplateDemo() {
  const itemRenderer = (item, options) => (
    <>
      <a
        className="flex align-items-center px-3 py-2 cursor-pointer"
        onClick={options.onClick}
      >
        <span className={`${item.icon} text-primary`} />
        <span className={`mx-2 ${item.items && 'font-semibold'}`}>
          {item.label}
        </span>
        {item.badge && <Badge className="ml-auto" value={item.badge} />}
        {item.shortcut && (
          <span className="ml-auto border-1 surface-border border-round surface-100 text-xs p-1">
            {item.shortcut}
          </span>
        )}
      </a>
      <input type="text" />
    </>
  );

  const items: MenuItem[] = [
    {
      label: 'Mail',
      icon: 'pi pi-envelope',
      badge: 5,
      items: [
        {
          label: 'Compose',
          icon: 'pi pi-file-edit',
          shortcut: '⌘+N',
          template: itemRenderer,
        },
        {
          label: 'Inbox',
          icon: 'pi pi-inbox',
          badge: 5,
          template: itemRenderer,
        },
        {
          label: 'Sent',
          icon: 'pi pi-send',
          shortcut: '⌘+S',
          template: itemRenderer,
        },
        {
          label: 'Trash',
          icon: 'pi pi-trash',
          shortcut: '⌘+T',
          template: itemRenderer,
        },
      ],
    },
    {
      label: 'Reports',
      icon: 'pi pi-chart-bar',
      shortcut: '⌘+R',
      items: [
        {
          label: 'Sales',
          icon: 'pi pi-chart-line',
          badge: 3,
          template: itemRenderer,
        },
        {
          label: 'Products',
          icon: 'pi pi-list',
          badge: 6,
          template: itemRenderer,
        },
      ],
    },
    {
      label: 'Profile',
      icon: 'pi pi-user',
      shortcut: '⌘+W',
      items: [
        {
          label: 'Settings',
          icon: 'pi pi-cog',
          shortcut: '⌘+O',
          template: itemRenderer,
        },
        {
          label: 'Privacy',
          icon: 'pi pi-shield',
          shortcut: '⌘+P',
          template: itemRenderer,
        },
      ],
    },
  ];
  return (
    <div className="card flex justify-content-center">
      <PanelMenu model={items} className="w-full md:w-20rem" />
    </div>
  );
}

you can't write anything in inputText it will give error

Reproducer

No response

PrimeReact version

10.6.3

React version

18.x

Language

TypeScript

Build / Runtime

Create React App (CRA)

Browser(s)

No response

Steps to reproduce the behavior

  1. use PanelMenu and in it's item use template
  2. in this template use InputText
  3. this inputText will not allow you to write anything and will give you console error

Expected behavior

inputText field should work

@Usamacs66 Usamacs66 added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Apr 17, 2024
@melloware melloware added Status: Needs Reproducer Issue needs a runnable reproducer and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Apr 17, 2024
Copy link

Please fork the Stackblitz project and create a case demonstrating your bug report. This issue will be closed if no activities in 20 days.

@Usamacs66
Copy link
Author

Usamacs66 commented Apr 17, 2024

Click on this link to reproduce it https://stackblitz.com/edit/nuru9h-g8nwgy?file=src%2FApp.tsx
try to write something in Input Text field

@melloware
Copy link
Member

melloware commented Apr 17, 2024

So PanelMenu is NOT an input component...its a menu. So its ARIA accessibility keyboard handling is stealing the focus from your Input. This is not a correct UI paradigm you want to use Accordion: https://primereact.org/accordion/

@melloware melloware added Resolution: Invalid Issue or pull request is not valid in the latest version and removed Status: Needs Reproducer Issue needs a runnable reproducer labels Apr 17, 2024
@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Invalid Issue or pull request is not valid in the latest version
Projects
None yet
Development

No branches or pull requests

2 participants