mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[embeddable] fix race condition in useStateFromPublishingSubject (#216522)
Related to https://github.com/elastic/kibana/pull/216399 PR * updates `useStateFromPublishingSubject` to require `subject`, thus, removing complexities of setting up subscription when `subject` is optionally provided. * Updates `useStateFromPublishingSubject` to setup subscription with `useMemo` to avoid timing issues. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
4c3274d3a2
commit
5a3c2c0f05
11 changed files with 102 additions and 96 deletions
|
@ -12,8 +12,8 @@ import { css } from '@emotion/react';
|
|||
import { ReactEmbeddableFactory } from '@kbn/embeddable-plugin/public';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import {
|
||||
getViewModeSubject,
|
||||
initializeTitleManager,
|
||||
useInheritedViewMode,
|
||||
useStateFromPublishingSubject,
|
||||
} from '@kbn/presentation-publishing';
|
||||
import React from 'react';
|
||||
|
@ -78,7 +78,9 @@ export const markdownEmbeddableFactory: ReactEmbeddableFactory<
|
|||
Component: () => {
|
||||
// get state for rendering
|
||||
const content = useStateFromPublishingSubject(content$);
|
||||
const viewMode = useInheritedViewMode(api) ?? 'view';
|
||||
const viewMode = useStateFromPublishingSubject(
|
||||
getViewModeSubject(api) ?? new BehaviorSubject('view')
|
||||
);
|
||||
const { euiTheme } = useEuiTheme();
|
||||
|
||||
return viewMode === 'edit' ? (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue