kibana/examples
Hannah Mudge 2a76fe3ee4
[Dashboard] [Collapsable Panels] Add embeddable support (#198413)
Closes https://github.com/elastic/kibana/issues/190379

## Summary

This PR switches the example grid layout app to render embeddables as
panels rather than the simplified mock panel we were using previously.
In doing so, I had to add the ability for custom panels to add a custom
drag handle via the `renderPanelContents` callback - this required
adding a `setDragHandles` callback to the `ReactEmbeddableRenderer` that
could be passed down to the `PresentationPanel` component.




https://github.com/user-attachments/assets/9e2c68f9-34af-4360-a978-9113701a5ea2



#### New scroll behaviour

In https://github.com/elastic/kibana/pull/201867, I introduced a small
"ease" to the auto-scroll effect that happens when you drag a panel to
the top or bottom of the window. However, in that PR, I was using the
`smooth` scrolling behaviour, which unfortunately became **very**
jittery once I switched to embeddables rather than simple panels
(specifically in Chrome - it worked fine in Firefox).

The only way to prevent this jittery scroll was to switch to the default
scroll behaviour, but this lead to a very **abrupt** stop when the
scrollbar reached the top and/or bottom of the page - so, to give the
same "gentle" stop that the `smooth` scroll had, I decided to recreate
this effect by adding a slow down "ease" when close to the top or bottom
of the page:


https://github.com/user-attachments/assets/cb7bf03f-4a9e-4446-be4f-8f54c0bc88ac

This effect is accomplished via the parabola formula `y = a(x-h)2 + k`
and can be roughly visualized with the following, which shows that the
"speed up" ease happens at a much slower pace than the "slow down" ease:


![image](https://github.com/user-attachments/assets/02b4389c-fe78-448d-9c02-c4ec5e722d5e)




#### Notes about parent changes
As I investigated improving the efficiency of the grid layout with
embeddables, one of the main things I noticed was that the grid panel
was **always** remounted when moving a panel from one collapsible
section to another. This lead me (and @ThomThomson) down a rabbit hole
of React-reparenting, and we explored a few different options to see if
we could change the parent of a component **without** having it remount.

In summary, after various experiments and a whole bunch of research, we
determined that, due to the reconciliation of the React tree, this is
unfortunately impossible. So our priorities will instead have to move to
making the remount of `ReactEmbeddableRenderer` **as efficient as
possible** via caching, since the remount is inevitable.

### Checklist

- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

### Identify risks

There are no risks to this PR, since the most significant work is
contained in the `examples` plugin. Some changes were made to the
presentation panel to allow for custom drag handles, but this isn't
actually used in Dashboard - so for now, this code is only called in the
example plugin, as well.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-12-10 11:14:31 -06:00
..
bfetch_explorer Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
content_management_examples [EuiInMemoryTable] Persist table rows per page and sort (#198297) 2024-11-18 07:35:26 -06:00
controls_example [Embeddable Rebuild] [Controls] Remove non-React controls from controls plugin (#192017) 2024-09-17 08:12:54 -06:00
data_view_field_editor_example Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
developer_examples Preparation for High Contrast Mode, Core/SharedUX domains (#202606) 2024-12-05 08:26:41 -07:00
discover_customization_examples [OneDiscover] Contextual App Menu Extension Point (#195448) 2024-10-30 13:35:15 +01:00
embeddable_examples [Dashboard] [Collapsable Panels] Add embeddable support (#198413) 2024-12-10 11:14:31 -06:00
error_boundary Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
eso_model_version_example Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
esql_ast_inspector Sustainable Kibana Architecture: Move modules owned by @elastic/kibana-esql (#202722) 2024-12-09 11:33:55 +01:00
esql_validation_example Sustainable Kibana Architecture: Move modules owned by @elastic/kibana-esql (#202722) 2024-12-09 11:33:55 +01:00
expressions_explorer Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
feature_control_examples Added scope field to features config. (#191634) 2024-09-12 19:22:20 -05:00
feature_flags_example [Feature Flags Example Plugin] Change ctx provider (#201097) 2024-11-21 06:01:02 -06:00
field_formats_example Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
files_example Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
grid_example [Dashboard] [Collapsable Panels] Add embeddable support (#198413) 2024-12-10 11:14:31 -06:00
guided_onboarding_example [Expamples][Guided onboarding] - added missing EuiProvider to fix errors (#199070) 2024-11-05 20:17:16 -06:00
hello_world Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
locator_examples Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
locator_explorer Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
partial_results_example Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
portable_dashboards_example [dashboard] decouple DashboardCreationOptions from DashboardContainer (#194875) 2024-10-07 14:43:12 -06:00
preboot_example Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
resizable_layout_examples Sustainable Kibana Architecture: Categorise straightforward packages (#199630) 2024-11-22 10:33:25 +01:00
response_stream [ML] AIOps: Log Rate Analysis embeddable (#197943) 2024-11-05 15:48:45 +01:00
routing_example Preparation for High Contrast Mode, Core/SharedUX domains (#202606) 2024-12-05 08:26:41 -07:00
screenshot_mode_example Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
search_examples Sustainable Kibana Architecture: Categorise straightforward packages (#199630) 2024-11-22 10:33:25 +01:00
share_examples [Reporting] fix dashboard "Copy Post URL" action (#192530) 2024-10-08 01:54:21 +02:00
state_containers_examples Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
ui_action_examples Preparation for High Contrast Mode, Core/SharedUX domains (#202606) 2024-12-05 08:26:41 -07:00
ui_actions_explorer Preparation for High Contrast Mode, Core/SharedUX domains (#202606) 2024-12-05 08:26:41 -07:00
unified_doc_viewer Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
unified_field_list_examples Sustainable Kibana Architecture: Categorise straightforward packages (#199630) 2024-11-22 10:33:25 +01:00
user_profile_examples Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
v8_profiler_examples Adds AGPL 3.0 license (#192025) 2024-09-06 19:02:41 -06:00
README.asciidoc Adds run without basepath configured to examples readme (#173086) 2023-12-12 11:22:02 -07:00

[[example-plugins]]
== Example plugins

This folder contains example plugins.  To run the plugins in this folder, use the `--run-examples` flag (without a basepath), via

[source,bash]
----
yarn start --run-examples
----