Skip to content

Commit

Permalink
[8.16] [Canvas] Fix bug when trying to move elements (elastic#199211) (
Browse files Browse the repository at this point in the history
…elastic#199245)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[Canvas] Fix bug when trying to move elements
(elastic#199211)](elastic#199211)

<!--- 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-11-06T23:54:44Z","message":"[Canvas]
Fix bug when trying to move elements (elastic#199211)\n\nCloses
https://github.com/elastic/kibana/issues/199110\r\n\r\n##
Summary\r\n\r\nIn elastic#194634, we
switched to\r\nhard-coded strings for the reducers to prevent an import
circular\r\ndependency -
see\r\nhttps://github.com/elastic/pull/194634/files#diff-12e4182415d9eb779aadf492d2b777393e2794c7ac2eb39c48310ab6493ab233L115-R120\r\nfor
the relevant change.\r\n\r\nWhat we didn't realize at the time, however,
is that there was actually\r\na typo in the original creation of the set
position action - the\r\n`actionType` was set to the singular
`setMultiplePosition` rather than\r\n`setMultiplePositions`, so there
was actually **no** reducer tied to the\r\n`setMultiplePositions` action
type after our change - i.e. the reducer\r\nmap was expecting
`setMultiplePosition` and did nothing for\r\n`setMultiplePositions`. By
changing the `actionType` to the proper\r\nplural
`setMultiplePositions`, the reducer map now has a match, so
the\r\nreducer gets called as expected.\r\n\r\n| Before | After
|\r\n|--------|--------|\r\n|
![Nov-06-2024\r\n14-04-37](https://github.com/user-attachments/assets/627a3fee-2835-446a-b949-f44632d797d3)\r\n|
![Nov-06-2024\r\n14-05-19](https://github.com/user-attachments/assets/f0baed94-3858-47b7-b979-7f27deb50b08)\r\n|\r\n\r\nI
looked through the other changes we made to reducer map keys,
and\r\nevery `actionType` defined via `createAction` seems to have a
matching\r\nreducer map key - so this appears to be a one-off
🙈\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###
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)","sha":"1fa30899ab2ba3f534ebb6620a34513a1431e0ed","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","loe:small","impact:critical","v9.0.0","Feature:Canvas","backport:version","v8.17.0","v8.16.1","v8.18.0"],"title":"[Canvas]
Fix bug when trying to move
elements","number":199211,"url":"https://github.com/elastic/kibana/pull/199211","mergeCommit":{"message":"[Canvas]
Fix bug when trying to move elements (elastic#199211)\n\nCloses
https://github.com/elastic/kibana/issues/199110\r\n\r\n##
Summary\r\n\r\nIn elastic#194634, we
switched to\r\nhard-coded strings for the reducers to prevent an import
circular\r\ndependency -
see\r\nhttps://github.com/elastic/pull/194634/files#diff-12e4182415d9eb779aadf492d2b777393e2794c7ac2eb39c48310ab6493ab233L115-R120\r\nfor
the relevant change.\r\n\r\nWhat we didn't realize at the time, however,
is that there was actually\r\na typo in the original creation of the set
position action - the\r\n`actionType` was set to the singular
`setMultiplePosition` rather than\r\n`setMultiplePositions`, so there
was actually **no** reducer tied to the\r\n`setMultiplePositions` action
type after our change - i.e. the reducer\r\nmap was expecting
`setMultiplePosition` and did nothing for\r\n`setMultiplePositions`. By
changing the `actionType` to the proper\r\nplural
`setMultiplePositions`, the reducer map now has a match, so
the\r\nreducer gets called as expected.\r\n\r\n| Before | After
|\r\n|--------|--------|\r\n|
![Nov-06-2024\r\n14-04-37](https://github.com/user-attachments/assets/627a3fee-2835-446a-b949-f44632d797d3)\r\n|
![Nov-06-2024\r\n14-05-19](https://github.com/user-attachments/assets/f0baed94-3858-47b7-b979-7f27deb50b08)\r\n|\r\n\r\nI
looked through the other changes we made to reducer map keys,
and\r\nevery `actionType` defined via `createAction` seems to have a
matching\r\nreducer map key - so this appears to be a one-off
🙈\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###
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)","sha":"1fa30899ab2ba3f534ebb6620a34513a1431e0ed"}},"sourceBranch":"main","suggestedTargetBranches":["8.x","8.16","8.18"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/199211","number":199211,"mergeCommit":{"message":"[Canvas]
Fix bug when trying to move elements (elastic#199211)\n\nCloses
https://github.com/elastic/kibana/issues/199110\r\n\r\n##
Summary\r\n\r\nIn elastic#194634, we
switched to\r\nhard-coded strings for the reducers to prevent an import
circular\r\ndependency -
see\r\nhttps://github.com/elastic/pull/194634/files#diff-12e4182415d9eb779aadf492d2b777393e2794c7ac2eb39c48310ab6493ab233L115-R120\r\nfor
the relevant change.\r\n\r\nWhat we didn't realize at the time, however,
is that there was actually\r\na typo in the original creation of the set
position action - the\r\n`actionType` was set to the singular
`setMultiplePosition` rather than\r\n`setMultiplePositions`, so there
was actually **no** reducer tied to the\r\n`setMultiplePositions` action
type after our change - i.e. the reducer\r\nmap was expecting
`setMultiplePosition` and did nothing for\r\n`setMultiplePositions`. By
changing the `actionType` to the proper\r\nplural
`setMultiplePositions`, the reducer map now has a match, so
the\r\nreducer gets called as expected.\r\n\r\n| Before | After
|\r\n|--------|--------|\r\n|
![Nov-06-2024\r\n14-04-37](https://github.com/user-attachments/assets/627a3fee-2835-446a-b949-f44632d797d3)\r\n|
![Nov-06-2024\r\n14-05-19](https://github.com/user-attachments/assets/f0baed94-3858-47b7-b979-7f27deb50b08)\r\n|\r\n\r\nI
looked through the other changes we made to reducer map keys,
and\r\nevery `actionType` defined via `createAction` seems to have a
matching\r\nreducer map key - so this appears to be a one-off
🙈\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###
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)","sha":"1fa30899ab2ba3f534ebb6620a34513a1431e0ed"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.16","label":"v8.16.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Hannah Mudge <[email protected]>
  • Loading branch information
kibanamachine and Heenawter authored Nov 7, 2024
1 parent 353ad66 commit e63d4ec
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions x-pack/plugins/canvas/public/state/actions/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,12 @@ function getBareElement(el, includeId = false) {

export const elementLayer = createAction('elementLayer');

export const setMultiplePositions = createAction('setMultiplePosition', (repositionedElements) => ({
repositionedElements,
}));
export const setMultiplePositions = createAction(
'setMultiplePositions',
(repositionedElements) => ({
repositionedElements,
})
);

export const flushContext = createAction('flushContext');
export const flushContextAfterIndex = createAction('flushContextAfterIndex');
Expand Down

0 comments on commit e63d4ec

Please sign in to comment.