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

[Embeddable Rebuild] [Controls] Refactor control editing + creation #187606

Conversation

Heenawter
Copy link
Contributor

@Heenawter Heenawter commented Jul 4, 2024

Closes #187504

Summary

This PR changes how control creation/editing is handled in the new system by changing from a state manager to an explicit initialState + updateState callback structure. Unfortunately, the stateManager system really only works if we had inline creation for controls - since we don't have that, the embeddable (and hence the stateManager) doesn't exist until after the editor is saved. Therefore, especially with respect to the custom options component, we had no way of knowing what keys the stateManager should include when trying to create a new control. The new system isn't quite as clean IMO, but it works better for our current goals with this refactor. We can revisit the stateManager idea once controls support inline editing 👍

This PR also fixes a few visual bugs, noted below.

Checklist

For maintainers

@Heenawter Heenawter added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas loe:medium Medium Level of Effort impact:critical This issue should be addressed immediately due to a critical level of impact on the product. Project:Controls project:embeddableRebuild labels Jul 4, 2024
@Heenawter Heenawter self-assigned this Jul 4, 2024
@Heenawter Heenawter added the release_note:skip Skip the PR/issue when compiling release notes label Jul 4, 2024
@Heenawter Heenawter force-pushed the embeddableRebuild_controls_add-creation_2024-07-03 branch from 22044c0 to 609a2f2 Compare July 5, 2024 15:57
@Heenawter
Copy link
Contributor Author

/ci

@Heenawter
Copy link
Contributor Author

/ci

Comment on lines +16 to +22
.controlPanel--label {
@include euiTextTruncate;
background-color: transparent;
border-radius: $euiBorderRadius;
margin-left: 0 !important;
padding-left: 0 !important;
}
Copy link
Contributor Author

@Heenawter Heenawter Jul 8, 2024

Choose a reason for hiding this comment

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

This fixes a style error where the truncation was happening before the max-width applied, so labels were getting cut off too early on the "small" control size. I also verified that the truncation now happens at the same point that it does for the old controls, so there should be no visual changes from the user's perspective once the React controls are officially swapped in Dashboard.

Before After Legacy
image image image
image image image

Comment on lines +150 to +157
<EuiToolTip
anchorClassName="controlPanel--labelWrapper"
content={panelTitle || defaultPanelTitle}
>
<EuiFormLabel className="controlPanel--label">
{panelTitle || defaultPanelTitle}
</EuiFormLabel>
</EuiToolTip>
Copy link
Contributor Author

@Heenawter Heenawter Jul 8, 2024

Choose a reason for hiding this comment

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

I accidentally forgot to include the tooltip when initially building this, but we need it for when things get truncated.

@@ -22,6 +22,7 @@
}

.rangeSliderAnchor__fieldNumber {
min-width: auto !important;
Copy link
Contributor Author

@Heenawter Heenawter Jul 8, 2024

Choose a reason for hiding this comment

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

This fixes a bug where the step arrows were being cut off on the small size:

Before After
image image

@Heenawter
Copy link
Contributor Author

/ci

CustomOptionsComponent: ({ stateManager, setControlEditorValid }) => {
const step = useStateFromPublishingSubject(stateManager.step);
CustomOptionsComponent: ({ initialState, updateState, setControlEditorValid }) => {
const [step, setStep] = useState(initialState.step ?? 1);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default to 1 needs to happen here too, specifically for creation.

@Heenawter
Copy link
Contributor Author

/ci

@nreese nreese self-requested a review July 8, 2024 19:11
@Heenawter Heenawter requested a review from nreese July 10, 2024 21:37
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, tested in chrome

@Heenawter Heenawter enabled auto-merge (squash) July 15, 2024 15:45
Copy link
Contributor

@ryankeairns ryankeairns left a comment

Choose a reason for hiding this comment

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

Thanks for the screenshots! That was super helpful.

@Heenawter Heenawter merged commit 23bb3c1 into elastic:main Jul 17, 2024
24 checks passed
@kibanamachine kibanamachine added v8.16.0 backport:skip This commit does not require backporting labels Jul 17, 2024
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

cc @Heenawter

@Heenawter Heenawter deleted the embeddableRebuild_controls_add-creation_2024-07-03 branch July 17, 2024 23:27
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 impact:critical This issue should be addressed immediately due to a critical level of impact on the product. loe:medium Medium Level of Effort Project:Controls project:embeddableRebuild release_note:skip Skip the PR/issue when compiling release notes Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Embeddable Rebuild] [Controls] Fix control creation
5 participants