[8.7] [Controls] Discard control grow changes on cancel (#151522) (#151787)

# Backport

This will backport the following commits from `main` to `8.7`:
- [[Controls] Discard control grow changes on cancel
(#151522)](https://github.com/elastic/kibana/pull/151522)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Hannah
Mudge","email":"Heenawter@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-02-21T20:10:38Z","message":"[Controls]
Discard control grow changes on cancel (#151522)\n\nCloses
https://github.com/elastic/kibana/issues/151206\r\n\r\n##
Summary\r\n\r\nThis PR ensures that changes to the control group `grow`
property (a)\r\ntriggers the `Discard changes` warning modal and (b)
when the modal is\r\nconfirmed, the changes are indeed
discarded.\r\n\r\n\r\nhttps://user-images.githubusercontent.com/8698078/220419614-4cac86d9-7fd3-40f5-8c39-ef5994b11947.mov\r\n\r\n<br>\r\n\r\nWhile
this fixes the attached **bug**, it raises another issue on\r\nwhether
or not the behaviour of auto-applying changes to the
control's\r\nwidth/grow properties is even desired - this can be tracked
in\r\nhttps://github.com/elastic/kibana/issues/151767.\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###
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#kibana-release-notes-process)","sha":"1d1848e96c6d28f9ef46803825f996f9fa3b5430","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Feature:Dashboard","release_note:fix","Feature:Input
Control","Team:Presentation","loe:days","impact:high","Project:Controls","backport:prev-minor","v8.8.0"],"number":151522,"url":"https://github.com/elastic/kibana/pull/151522","mergeCommit":{"message":"[Controls]
Discard control grow changes on cancel (#151522)\n\nCloses
https://github.com/elastic/kibana/issues/151206\r\n\r\n##
Summary\r\n\r\nThis PR ensures that changes to the control group `grow`
property (a)\r\ntriggers the `Discard changes` warning modal and (b)
when the modal is\r\nconfirmed, the changes are indeed
discarded.\r\n\r\n\r\nhttps://user-images.githubusercontent.com/8698078/220419614-4cac86d9-7fd3-40f5-8c39-ef5994b11947.mov\r\n\r\n<br>\r\n\r\nWhile
this fixes the attached **bug**, it raises another issue on\r\nwhether
or not the behaviour of auto-applying changes to the
control's\r\nwidth/grow properties is even desired - this can be tracked
in\r\nhttps://github.com/elastic/kibana/issues/151767.\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###
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#kibana-release-notes-process)","sha":"1d1848e96c6d28f9ef46803825f996f9fa3b5430"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151522","number":151522,"mergeCommit":{"message":"[Controls]
Discard control grow changes on cancel (#151522)\n\nCloses
https://github.com/elastic/kibana/issues/151206\r\n\r\n##
Summary\r\n\r\nThis PR ensures that changes to the control group `grow`
property (a)\r\ntriggers the `Discard changes` warning modal and (b)
when the modal is\r\nconfirmed, the changes are indeed
discarded.\r\n\r\n\r\nhttps://user-images.githubusercontent.com/8698078/220419614-4cac86d9-7fd3-40f5-8c39-ef5994b11947.mov\r\n\r\n<br>\r\n\r\nWhile
this fixes the attached **bug**, it raises another issue on\r\nwhether
or not the behaviour of auto-applying changes to the
control's\r\nwidth/grow properties is even desired - this can be tracked
in\r\nhttps://github.com/elastic/kibana/issues/151767.\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###
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#kibana-release-notes-process)","sha":"1d1848e96c6d28f9ef46803825f996f9fa3b5430"}}]}]
BACKPORT-->

Co-authored-by: Hannah Mudge <Heenawter@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2023-02-21 16:19:28 -05:00 committed by GitHub
parent b5ac60cdc5
commit da5a79404a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -83,7 +83,8 @@ export const EditControlButton = ({ embeddableId }: { embeddableId: string }) =>
...panel.explicitInput,
...inputToReturn,
}) &&
isEqual(latestPanelState.current.width, panel.width))
isEqual(latestPanelState.current.width, panel.width) &&
isEqual(latestPanelState.current.grow, panel.grow))
) {
reject();
ref.close();
@ -97,6 +98,7 @@ export const EditControlButton = ({ embeddableId }: { embeddableId: string }) =>
}).then((confirmed) => {
if (confirmed) {
dispatch(setControlWidth({ width: panel.width, embeddableId }));
dispatch(setControlGrow({ grow: panel.grow, embeddableId }));
reject();
ref.close();
}