dnbexperience / eufemia

DNB Design System
https://eufemia.dnb.no
Other
53 stars 32 forks source link

Key is being overwritten when using CustomContent #1192

Open whitneymarkov opened 2 years ago

whitneymarkov commented 2 years ago

https://github.com/dnbexperience/eufemia/blob/59825b88d99148d5e26a8f638ad39507e4661bc3/packages/dnb-eufemia/src/components/tabs/Tabs.js#L239

If there is an existing key ideally it would be used instead of the slugified title so that the on_change in the Tabs component returns the correct key. You are able to get around it by passing the hash prop the key.

Reproducible here: codesandbox Clicking a tab does not return the key as the selected_key.

tujoworker commented 2 years ago

Hi @whitneymarkov – thank you for getting touch and sorry for the late reply!

Do you want basically this change to happen?

key: key || (!_key && hash ? hash : _key) || slugify(title),

Can I ask what the motivation behind this is? Also, I'm not sure we actually can use key as a prop, as it is "as-of-today" reserved by React.