Skip to content
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

[Dashboard] Disable layout changes when panel is expanded #152054

Merged

Conversation

cqliu1
Copy link
Contributor

@cqliu1 cqliu1 commented Feb 24, 2023

Summary

Closes #152052.

This ignores dashboard layout changes when a panel is expanded to prevent accidental layout changes. This also cleans up some of the CSS for maximized panel to look more similar to a single panel on a dashboard and hides the resize handle in the bottom right corner.

One additional CSS change included in this PR is I switched the embeddable panel dashed border to a dashed outline to prevent panel resizing between view/edit mode.

Maximized Panel

Before After
Screenshot 2023-02-23 at 4 40 26 PM Screenshot 2023-02-23 at 4 39 55 PM

Disabled dragging when maximized

Mar-20-2023 14-00-21

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

@cqliu1 cqliu1 added bug Fixes for quality problems that affect the customer experience Feature:Dashboard Dashboard related features Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. backport:skip This commit does not require backporting v8.8.0 labels Feb 24, 2023
@cqliu1 cqliu1 requested review from a team as code owners February 24, 2023 00:43
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@cqliu1 cqliu1 changed the title Disable layout changes when panel is expanded [Dashboard] Disable layout changes when panel is expanded Feb 24, 2023
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

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

LGTM
code review

// onLayoutChange gets called by react grid layout a lot more than it should, so only dispatch the updated panels if the layout has actually changed
if (!getPanelLayoutsAreEqual(panels, updatedPanels)) {
dispatch(setPanels(updatedPanels));
if (!expandedPanelId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Instead of nesting everything under if (!expandedPanelId), how about just returning early

if (expandedPanelId) {
  return;
}

@andreadelrio andreadelrio self-requested a review March 1, 2023 19:50
@@ -68,14 +68,13 @@ function ResponsiveGrid({
});

const MARGINS = useMargins ? 8 : 0;
// We can't take advantage of isDraggable or isResizable due to performance concerns:
// https://github.com/STRML/react-grid-layout/issues/240
Copy link
Contributor Author

@cqliu1 cqliu1 Mar 2, 2023

Choose a reason for hiding this comment

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

This performance concern mentioned here is that react-grid-layout children were unmounted when isDraggable and isResizable were dynamically changed. This issue has since been resolved with this fix which went into RGL v0.81.0, and we're currently on v1.3.4.

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

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

Looked through the code and tested this locally. Everything works great!

As discussed offline, would love to see a performance comparison using the isResizable / isDraggable strategy vs pure CSS just for peace of mind.

@@ -33,6 +33,10 @@
*/
.dshLayout-isMaximizedPanel {
height: 100% !important; /* 1. */

.react-resizable-handle {
display: none; /* 1 */
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Is this still needed now that we have the isResizable set to false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like this isn't necessary anymore after setting isResizable to false. I'll remove this

@@ -21,4 +19,9 @@
.embPanel {
border-color: transparent;
}

.embPanel--dragHandle:hover {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this new style for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is to keep the title bar from setting that yellow background and prevent the cursor from changing to the move cursor to override styles defined by the embeddable plugin.

@cqliu1
Copy link
Contributor Author

cqliu1 commented Mar 20, 2023

I ran the performance profiler for loading a dashboard, switching from view mode to edit mode, and switching from edit mode to view mode. There are no significant differences in loading times afaict.

Loading dashboard

Main This PR

View Mode -> Edit Mode

Main This PR

Edit Mode -> View Mode

Main This PR

@ThomThomson
Copy link
Contributor

ThomThomson commented Mar 20, 2023

Amazing, thank you for doing those profiles! Definitely adds to my confidence in this PR.

@botelastic botelastic bot added the Feature:Embedding Embedding content via iFrame label Mar 20, 2023
Copy link
Contributor

@andreadelrio andreadelrio left a comment

Choose a reason for hiding this comment

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

I think it'd be good to have an indicator for users to know that a panel is maximized (see screenshot below) but we can tackle that in a follow-up.

Frame 454

Nice job @cqliu1 !

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
dashboard 386.7KB 387.5KB +880.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
embeddable 75.3KB 75.3KB +6.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
securitySolution 433 436 +3

Total ESLint disabled count

id before after diff
securitySolution 513 516 +3

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@cqliu1 cqliu1 merged commit 16de10b into elastic:main Mar 21, 2023
@cqliu1 cqliu1 deleted the dashboard/disable-layout-changes-in-maximize branch March 21, 2023 15:10
nkhristinin pushed a commit that referenced this pull request Mar 22, 2023
## Summary

Closes #152052.

This ignores dashboard layout changes when a panel is expanded to
prevent accidental layout changes. This also cleans up some of the CSS
for maximized panel to look more similar to a single panel on a
dashboard and hides the resize handle in the bottom right corner.

One additional CSS change included in this PR is I switched the
embeddable panel dashed border to a dashed outline to prevent panel
resizing between view/edit mode.

### Maximized Panel 
 Before | After 
 :------: | :------: 
![Screenshot 2023-02-23 at 4 40 26
PM](https://user-images.githubusercontent.com/1697105/221063721-34a63f96-a7fe-4fab-a21d-c1108f4ba63d.png)
| ![Screenshot 2023-02-23 at 4 39 55
PM](https://user-images.githubusercontent.com/1697105/221063765-a7da2c8e-8e60-469a-b607-872a8c3957aa.png)

### Disabled dragging when maximized
![Mar-20-2023
14-00-21](https://user-images.githubusercontent.com/1697105/226464826-1882fbcd-cfcb-471c-8e6c-e795d0c3762b.gif)


### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces—unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes—Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
tsullivan pushed a commit to tsullivan/kibana that referenced this pull request Mar 22, 2023
…2054)

## Summary

Closes elastic#152052.

This ignores dashboard layout changes when a panel is expanded to
prevent accidental layout changes. This also cleans up some of the CSS
for maximized panel to look more similar to a single panel on a
dashboard and hides the resize handle in the bottom right corner.

One additional CSS change included in this PR is I switched the
embeddable panel dashed border to a dashed outline to prevent panel
resizing between view/edit mode.

### Maximized Panel 
 Before | After 
 :------: | :------: 
![Screenshot 2023-02-23 at 4 40 26
PM](https://user-images.githubusercontent.com/1697105/221063721-34a63f96-a7fe-4fab-a21d-c1108f4ba63d.png)
| ![Screenshot 2023-02-23 at 4 39 55
PM](https://user-images.githubusercontent.com/1697105/221063765-a7da2c8e-8e60-469a-b607-872a8c3957aa.png)

### Disabled dragging when maximized
![Mar-20-2023
14-00-21](https://user-images.githubusercontent.com/1697105/226464826-1882fbcd-cfcb-471c-8e6c-e795d0c3762b.gif)


### Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
- [ ]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] Any UI touched in this PR is usable by keyboard only (learn more
about [keyboard accessibility](https://webaim.org/techniques/keyboard/))
- [ ] Any UI touched in this PR does not create any new axe failures
(run axe in browser:
[FF](https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/),
[Chrome](https://chrome.google.com/webstore/detail/axe-web-accessibility-tes/lhdoppojpmngadmnindnejefpokejbdd?hl=en-US))
- [ ] If a plugin configuration key changed, check if it needs to be
allowlisted in the cloud and added to the [docker
list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)
- [ ] This renders correctly on smaller devices using a responsive
layout. (You can test this [in your
browser](https://www.browserstack.com/guide/responsive-testing-on-local-server))
- [ ] This was checked for [cross-browser
compatibility](https://www.elastic.co/support/matrix#matrix_browsers)


### Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to
identify risks that should be tested prior to the change/feature
release.

When forming the risk matrix, consider some of the following examples
and how they may potentially impact the change:

| Risk | Probability | Severity | Mitigation/Notes |

|---------------------------|-------------|----------|-------------------------|
| Multiple Spaces—unexpected behavior in non-default Kibana Space.
| Low | High | Integration tests will verify that all features are still
supported in non-default Kibana Space and when user switches between
spaces. |
| Multiple nodes—Elasticsearch polling might have race conditions
when multiple Kibana nodes are polling for the same tasks. | High | Low
| Tasks are idempotent, so executing them multiple times will not result
in logical error, but will degrade performance. To test for this case we
add plenty of unit tests around this logic and document manual testing
procedure. |
| Code should gracefully handle cases when feature X or plugin Y are
disabled. | Medium | High | Unit tests will verify that any feature flag
or plugin combination still results in our service operational. |
| [See more potential risk
examples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx) |


### For maintainers

- [ ] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting bug Fixes for quality problems that affect the customer experience Feature:Dashboard Dashboard related features Feature:Embedding Embedding content via iFrame impact:low Addressing this issue will have a low level of impact on the quality/strength of our product. loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.8.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Dashboard] Resizing/dragging a panel should be disabled while panel is maximized
7 participants