Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…198219) # Backport This will backport the following commits from `main` to `8.x`: - [[Dashboard] [Collapsable Panels] Reduce re-renders (#197343)](#197343) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Hannah Mudge","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-29T22:07:45Z","message":"[Dashboard] [Collapsable Panels] Reduce re-renders (#197343)\n\nCloses https://github.com/elastic/kibana/issues/191131\r\n\r\n## Summary\r\n\r\nThis PR greatly reduces the number of React re-renders that happen as\r\npanels get dragged around and/or resized. Now, the actions that trigger\r\na panel to get rendered are as follows:\r\n1. Obviously, when the grid first loads, every panel has to be rendered.\r\n2. When a panel gets dragged from one row to the next, both the original\r\nrow and the new row will re-render all of their panels because the panel\r\nIDs in both rows changed - however, because of the `key` prop on the\r\n`GridPanel` component, only the **dragged** panel will actually be fully\r\nre-mounted.\r\n3. When a panel gets collapsed and expanded, all panels in that row will\r\nget re-mounted and rendered.\r\n4. When a panel ID gets changed (this currently isn't possible, but in\r\ntheory, this would also trigger the panel to get re-rendered due to the\r\n`key` prop on the `GridPanel` component)\r\n\r\nIn order to accomplish this, we are now handling **all style changes**\r\nvia a subscription rather than setting the CSS directly; so, as the\r\n`gridLayout# Backport This will backport the following commits from `main` to `8.x`: - [[Dashboard] [Collapsable Panels] Reduce re-renders (#197343)](#197343) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT behaviour subjects publishes changes, we update the row +\r\npanel styles via the panel reference. This allows us to change how the\r\ngrid looks without triggering React to rerender the entire panel.\r\n\r\n**How to Test:**\r\nAdd a `console.log` to the `renderPanelContents` in\r\n`examples/grid_example/public/app.tsx` - this will tell you when a panel\r\nis getting re-rendered.\r\n\r\n### Checklist\r\n\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n- [ ] This will appear in the **Release Notes** and follow the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"b91fa562bb7663a119fdd9c22054560960f625a0","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Dashboard","Team:Presentation","loe:medium","release_note:skip","impact:high","v9.0.0","backport:prev-minor","Project:Collapsable Panels"],"title":"[Dashboard] [Collapsable Panels] Reduce re-renders","number":197343,"url":"https://github.com/elastic/kibana/pull/197343","mergeCommit":{"message":"[Dashboard] [Collapsable Panels] Reduce re-renders (#197343)\n\nCloses https://github.com/elastic/kibana/issues/191131\r\n\r\n## Summary\r\n\r\nThis PR greatly reduces the number of React re-renders that happen as\r\npanels get dragged around and/or resized. Now, the actions that trigger\r\na panel to get rendered are as follows:\r\n1. Obviously, when the grid first loads, every panel has to be rendered.\r\n2. When a panel gets dragged from one row to the next, both the original\r\nrow and the new row will re-render all of their panels because the panel\r\nIDs in both rows changed - however, because of the `key` prop on the\r\n`GridPanel` component, only the **dragged** panel will actually be fully\r\nre-mounted.\r\n3. When a panel gets collapsed and expanded, all panels in that row will\r\nget re-mounted and rendered.\r\n4. When a panel ID gets changed (this currently isn't possible, but in\r\ntheory, this would also trigger the panel to get re-rendered due to the\r\n`key` prop on the `GridPanel` component)\r\n\r\nIn order to accomplish this, we are now handling **all style changes**\r\nvia a subscription rather than setting the CSS directly; so, as the\r\n`gridLayout# Backport This will backport the following commits from `main` to `8.x`: - [[Dashboard] [Collapsable Panels] Reduce re-renders (#197343)](#197343) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT behaviour subjects publishes changes, we update the row +\r\npanel styles via the panel reference. This allows us to change how the\r\ngrid looks without triggering React to rerender the entire panel.\r\n\r\n**How to Test:**\r\nAdd a `console.log` to the `renderPanelContents` in\r\n`examples/grid_example/public/app.tsx` - this will tell you when a panel\r\nis getting re-rendered.\r\n\r\n### Checklist\r\n\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n- [ ] This will appear in the **Release Notes** and follow the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"b91fa562bb7663a119fdd9c22054560960f625a0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197343","number":197343,"mergeCommit":{"message":"[Dashboard] [Collapsable Panels] Reduce re-renders (#197343)\n\nCloses https://github.com/elastic/kibana/issues/191131\r\n\r\n## Summary\r\n\r\nThis PR greatly reduces the number of React re-renders that happen as\r\npanels get dragged around and/or resized. Now, the actions that trigger\r\na panel to get rendered are as follows:\r\n1. Obviously, when the grid first loads, every panel has to be rendered.\r\n2. When a panel gets dragged from one row to the next, both the original\r\nrow and the new row will re-render all of their panels because the panel\r\nIDs in both rows changed - however, because of the `key` prop on the\r\n`GridPanel` component, only the **dragged** panel will actually be fully\r\nre-mounted.\r\n3. When a panel gets collapsed and expanded, all panels in that row will\r\nget re-mounted and rendered.\r\n4. When a panel ID gets changed (this currently isn't possible, but in\r\ntheory, this would also trigger the panel to get re-rendered due to the\r\n`key` prop on the `GridPanel` component)\r\n\r\nIn order to accomplish this, we are now handling **all style changes**\r\nvia a subscription rather than setting the CSS directly; so, as the\r\n`gridLayout# Backport This will backport the following commits from `main` to `8.x`: - [[Dashboard] [Collapsable Panels] Reduce re-renders (#197343)](#197343) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT behaviour subjects publishes changes, we update the row +\r\npanel styles via the panel reference. This allows us to change how the\r\ngrid looks without triggering React to rerender the entire panel.\r\n\r\n**How to Test:**\r\nAdd a `console.log` to the `renderPanelContents` in\r\n`examples/grid_example/public/app.tsx` - this will tell you when a panel\r\nis getting re-rendered.\r\n\r\n### Checklist\r\n\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#_add_your_labels)\r\n- [ ] This will appear in the **Release Notes** and follow the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine <[email protected]>","sha":"b91fa562bb7663a119fdd9c22054560960f625a0"}}]}] BACKPORT--> Co-authored-by: Hannah Mudge <[email protected]>
- Loading branch information