primefaces / primereact

The Most Complete React UI Component Library
https://primereact.org
MIT License
6.68k stars 1.01k forks source link

Dropdown: Loses value if value changed via ENTER key #6058

Open KRONTri opened 7 months ago

KRONTri commented 7 months ago

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.

melloware commented 7 months ago

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

espentveit commented 6 months ago

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

sja-cslab commented 4 months ago

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

melloware commented 2 months ago

Reverting this change.