Repository navigation
T1336765 - CardView — Cards are duplicated on updating dataSource if cardRender/cardComponent is used in React #35733
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
Open
bit-byte0
wants to merge
4
commits into
DevExpress:main
Choose a base branch
from
bit-byte0:fix/t1336765-cardview-react-template-duplicates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+224
−6
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
320291b
fix(grids): prevent CardView template duplicates and leaks (T1336765)
bit-byte0 21d1413
fix(grids): skip CardView template re-render on context change (T1336…
bit-byte0 88e93d4
refactor(react): drop render-time template container subscription
bit-byte0 cd1c5e1
fix(grids): clean CardView template container in place
bit-byte0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
e2e/wrappers/examples/card-view-template-rerender/react19/index.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import React, { useState } from "react"; | ||
| import CardView, { Column } from "devextreme-react/card-view"; | ||
|
|
||
| const initialData = [ | ||
| { id: 1, updateCount: 0 }, | ||
| { id: 2, updateCount: 0 }, | ||
| ]; | ||
|
|
||
| const renderCard = ({ card }) => ( | ||
| <div className="custom-card"> | ||
| {`${card.data.id}: ${card.data.updateCount}`} | ||
| </div> | ||
| ); | ||
|
|
||
| function App() { | ||
| const [items, setItems] = useState(initialData); | ||
|
|
||
| const updateItems = () => { | ||
| setItems((prev) => prev.map((item) => ({ | ||
| ...item, | ||
| updateCount: item.updateCount + 1, | ||
| }))); | ||
| }; | ||
|
|
||
| return ( | ||
| <div> | ||
| <button onClick={updateItems}>Update Data</button> | ||
|
|
||
| <CardView | ||
| dataSource={items} | ||
| keyExpr="id" | ||
| cardsPerRow={2} | ||
| cardRender={renderCard} | ||
| > | ||
| <Column dataField="id" /> | ||
| <Column dataField="updateCount" /> | ||
| </CardView> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| export default App; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { expect, test } from '../fixtures'; | ||
|
|
||
| test.describe('CardView template re-rendering', () => { | ||
| test.skip(({ framework }) => framework !== 'react19', 'The example is implemented for React only'); | ||
|
|
||
| test.beforeEach(async ({ page }) => { | ||
| await page.goto('/examples/card-view-template-rerender'); | ||
| }); | ||
|
|
||
| test('CardView should not duplicate card templates after a dataSource update (T1336765)', async ({ page }) => { | ||
| const updateButton = page.locator('button', { hasText: 'Update Data' }); | ||
| const cards = page.locator('.custom-card'); | ||
|
|
||
| await expect(cards).toHaveText(['1: 0', '2: 0']); | ||
|
|
||
| await updateButton.click(); | ||
|
|
||
| await expect(cards).toHaveText(['1: 1', '2: 1']); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.