Skip to content

[UI] Table field refactor#12274

Merged
SchrodingersGat merged 47 commits into
inventree:masterfrom
SchrodingersGat:table-field-fix
Jun 30, 2026
Merged

[UI] Table field refactor#12274
SchrodingersGat merged 47 commits into
inventree:masterfrom
SchrodingersGat:table-field-fix

Conversation

@SchrodingersGat

@SchrodingersGat SchrodingersGat commented Jun 29, 2026

Copy link
Copy Markdown
Member

Closes #11425

Breaking Change

Any custom plugins which use "table" field types in UI forms will need to adjust to match the new configuration. A unique ID value is required for each row.

Description

This PR addresses a major design inefficiency in the way that "table fields" are rendered in the user interface. It fixes a number of structural problems:

  • Removing any row causes all rows to be re-created
  • Updating any row causes all rows to be re-created
  • Each render takes multiple paint cycles

These issues were largely caused by:

  • Using the array index to identify each row (replaced with unique ID value)
  • Passing through too many props (now pass by ref)
  • Not memoizing props properly (now added a better memo step)

Performance Comparison

Before Refactor

before.mp4

After Refactor

after.mp4

@SchrodingersGat SchrodingersGat added this to the 1.5.0 milestone Jun 29, 2026
@SchrodingersGat SchrodingersGat added refactor User Interface Related to the frontend / User Interface bug Identifies a bug which needs to be addressed labels Jun 29, 2026
@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 4efca7e
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6a4374abdd7ee20008ac4422
😎 Deploy Preview https://deploy-preview-12274--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 92 (🔴 down 1 from production)
Accessibility: 82 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@SchrodingersGat SchrodingersGat requested a review from matmair June 29, 2026 14:26

@matmair matmair left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; this will require change on any plugins that use tables; right?

Comment thread src/frontend/src/components/forms/fields/TableField.tsx Outdated
Comment thread src/frontend/src/forms/BuildForms.tsx Outdated
Comment on lines +5 to +9
/**
* A custom hook that logs the previous and current props of a component whenever it updates.
*/
export function useWhyDidYouUpdate(name: string, props: any) {
const previousProps = useRef({});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should be mentioned in the docs?


return {
items: stockItems,
model: ModelType.stockitem,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo this could be helpful info in the future for plugins / customisation and should not cause re-renders

@SchrodingersGat SchrodingersGat added the breaking Indicates a major update or change which breaks compatibility label Jun 30, 2026
@SchrodingersGat

Copy link
Copy Markdown
Member Author

LGTM; this will require change on any plugins that use tables; right?

Yes, marked as breaking now. And I'll update the CHANGELOG

@SchrodingersGat SchrodingersGat merged commit 6111aac into inventree:master Jun 30, 2026
36 checks passed
@SchrodingersGat SchrodingersGat deleted the table-field-fix branch June 30, 2026 08:10
martonmiklos pushed a commit to martonmiklos/InvenTree that referenced this pull request Jun 30, 2026
* Use callback funcs

* Don't use idx to identify rows

* Add debug function for finding why a component re-rendered

* Do not pass 'control' through to each row

* Prevent unnecessary re-rendering of table rows

* Adjust order of operations for hooks

* Keep props hidden

* Use lightweight NumberInput

* Use NumberInput elsewhere

* Add comment

* use rowId instead of idx

* Generic row memos

* Compare errors too

* Fix for BomItemSubstituteRow

* Adjust more forms

* memoize quantity

* Memoize build lines

* Fix re-rendering issues for build allocation

* Fix for useConsumeBuildLinesForm

* Fix for transfer order table

* Fix useReceiveLineItems

* Remove memoized pattern

* Fix row keys

* Cleanup

* Create useStockItems hook for memoizing items

* Refactoring

* More refactoring

* Remove obj reference

- preventing shallow comparison from working

* Add error message to useWhyDidYouUpdate

* Cleanup

* Cleanup dead code

* Adjust modal width

* Change attr name

* Remove autoFillFilters prop

* Adjustments for serialized stock

* Fix typing

* Bump frontend version

* Adjustments for playwright testing

* Fix ref issue

* Remove debug entry

* Update CHANGELOG.md

* Reintroduce index to table header

* Refactor common component
martonmiklos pushed a commit to martonmiklos/InvenTree that referenced this pull request Jun 30, 2026
* Use callback funcs

* Don't use idx to identify rows

* Add debug function for finding why a component re-rendered

* Do not pass 'control' through to each row

* Prevent unnecessary re-rendering of table rows

* Adjust order of operations for hooks

* Keep props hidden

* Use lightweight NumberInput

* Use NumberInput elsewhere

* Add comment

* use rowId instead of idx

* Generic row memos

* Compare errors too

* Fix for BomItemSubstituteRow

* Adjust more forms

* memoize quantity

* Memoize build lines

* Fix re-rendering issues for build allocation

* Fix for useConsumeBuildLinesForm

* Fix for transfer order table

* Fix useReceiveLineItems

* Remove memoized pattern

* Fix row keys

* Cleanup

* Create useStockItems hook for memoizing items

* Refactoring

* More refactoring

* Remove obj reference

- preventing shallow comparison from working

* Add error message to useWhyDidYouUpdate

* Cleanup

* Cleanup dead code

* Adjust modal width

* Change attr name

* Remove autoFillFilters prop

* Adjustments for serialized stock

* Fix typing

* Bump frontend version

* Adjustments for playwright testing

* Fix ref issue

* Remove debug entry

* Update CHANGELOG.md

* Reintroduce index to table header

* Refactor common component
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Indicates a major update or change which breaks compatibility bug Identifies a bug which needs to be addressed refactor User Interface Related to the frontend / User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deleting rows to fast causes hiccup in the Allocate Stock for Build Order incomplete outputs form

2 participants