-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add dataKey property to DataView #1115
Comments
Whether a Dialog is open is based on the visible property, as you surely know. So when you say that the dialog changes I assume you are changing the visible properties of some dialogues. Hiding one and showing another. Your code snippet sadly doesn't show how you set that visible state. But I assume it's something like:
Without further information how you trigger your Dialogues I find it really hard to understand what you are talking about. |
Let's imagine there's a button rendered within each itemTemplate = ({ data }) => {
const [openDialog, setOpenDialog] = useState(false)
return (
<>
<button onClick={() => setOpenDialog(true)} />
<Dialog visible={openDialog}>
{data.field.text}
</Dialog>
</>
)
} |
Trying to recreate your Bug I'm stuck on this: https://i.imgur.com/LOUinEv.png Here is a sandbox of it: https://codesandbox.io/s/primereact-test-ceehk?fontsize=14&hidenavigation=1&theme=dark Could you provide a working sandbox of your problem? |
key
for itemTemplate
in DataView
causes funky behavior
Hi, I added dataKey property for it. You can use <DataView dataKey="id" .../>. Best Regards, |
I'm submitting a ... (check one with "x")
Current behavior
The DataView component has no way of specifying a custom
key
prop for the passed initemTemplate
component. This is problematic because, in my use case, each instance ofitemTemplate
has a modal within it that displays data passed in viaDataView
svalue
prop.Here's a simplified illustration
When the data set passed to the
value
prop changes while a user has a modal open, the information displayed in the modal unexpectedly changes. This is because thekey
for the currently displayeditemTemplate
is based on index only (see here, in the source code forDataView
)If I had the ability to override this key to be the identifier of my data rather than the index of the template that the
DataView
component is iterating over, then React would be smart enough to know that it should not change what is displayed in the modal.Minimal reproduction of the problem with instructions
DataView
as theitemTemplate
propDataView
value
prop ofDataView
to add on additional array itemitemTemplate
s information, since thevalue
array has changed length by one.I would expect the modal to not change.
React version:
16.8.6
PrimeReact version:
3.1.8
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
All
Language: [all | TypeScript X.X | ES6/7 | ES5]
Typescript
The text was updated successfully, but these errors were encountered: