primereact icon indicating copy to clipboard operation
primereact copied to clipboard

Dropdown: Loses value if value changed via ENTER key

Open KRONTri opened this issue 1 year ago • 4 comments

Describe the bug

Dropdown is empty as onChange event value property gets undefined if Dropdown has optionValue set.

Note: In the stackblitz I created two dropdowns. One with optionValue and one without. The one without is working as expected.

Reproducer

https://stackblitz.com/edit/vitejs-vite-tawz4r?file=src%2FApp.tsx

PrimeReact version

10.5.1

React version

18.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

Chrome 121

Steps to reproduce the behavior

  1. Open dropdown (via mouse or tabbing)
  2. Select a value with cursor keys
  3. Press ENTER

Expected behavior

After pressing ENTER value change should be reflected.

KRONTri avatar Feb 29 '24 09:02 KRONTri

Similar to: https://github.com/primefaces/primereact/issues/6035 Probably a similar fix is needed.

melloware avatar Feb 29 '24 12:02 melloware

Got the same issue. Seems to be that getOptionValue is called twice, where the result of the first is passed to the second. Causing it to not find the value.

Call stack: selectItem <- getOptionValue is called here onOptionSelect <- getOptionValue is called here onEnterKey onInputKeyDown

espentveit avatar Mar 15 '24 14:03 espentveit

@melloware seems not to be similar. You fixed #6035 in #6036 but this problem here is still there in 10.6.6

sja-cslab avatar May 27 '24 11:05 sja-cslab

Reverting this change.

melloware avatar Jul 14 '24 11:07 melloware