Skip to content

Commit

Permalink
[Dashboard] Disable layout changes when panel is expanded (#152054)
Browse files Browse the repository at this point in the history
## 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)
  • Loading branch information
cqliu1 authored Mar 21, 2023
1 parent da72f59 commit 16de10b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,18 @@
width: 100% !important; /* 1 */
top: 0 !important; /* 1 */
left: 0 !important; /* 1 */
padding: $euiSizeS;

// Altered panel styles can be found in ../panel
}

// Remove padding in fullscreen mode
.kbnAppWrapper--hiddenChrome {
.dshDashboardGrid__item--expanded {
padding: 0;
}
}

// REACT-GRID

.react-grid-item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

return (
<ReactGridLayout
width={lastValidGridSize}
className={classes}
isDraggable={true}
isResizable={true}
isDraggable={!maximizedPanelId}
isResizable={!maximizedPanelId}
// There is a bug with d3 + firefox + elements using transforms.
// See https://github.com/elastic/kibana/issues/16870 for more context.
useCSSTransforms={false}
Expand Down Expand Up @@ -177,6 +176,7 @@ export const DashboardGrid = () => {
},
{} as { [key: string]: DashboardPanelState }
);

// 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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
*/

// LAYOUT MODES

// Adjust borders/etc... for non-spaced out and expanded panels
.dshLayout-withoutMargins,
.dshDashboardGrid__item--expanded {
.dshLayout-withoutMargins {
.embPanel {
box-shadow: none;
border-radius: 0;
Expand All @@ -21,4 +19,9 @@
.embPanel {
border-color: transparent;
}

.embPanel--dragHandle:hover {
background-color: unset;
cursor: default;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@
// EDITING MODE

.embPanel--editing {
border-style: dashed !important;
border-color: $euiColorMediumShade !important;
outline-style: dashed !important;
outline-color: $euiColorMediumShade !important;
transition: all $euiAnimSpeedFast $euiAnimSlightResistance;
border-width: $euiBorderWidthThin;
outline-width: $euiBorderWidthThin;

&:hover,
&:focus {
Expand Down

0 comments on commit 16de10b

Please sign in to comment.