-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Improve vis editor typings #80004
Improve vis editor typings #80004
Conversation
Pinging @elastic/kibana-app (Team:KibanaApp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @timroes !
@@ -44,7 +44,7 @@ export const useSavedVisInstance = ( | |||
savedVisInstance?: SavedVisInstance; | |||
visEditorController?: IEditorController; | |||
}>({}); | |||
const visEditorRef = useRef<HTMLDivElement>(null); | |||
const visEditorRef = useRef<HTMLDivElement | null>(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Docs note:
if you need the result of useRef to be directly mutable, include | null in the type of the generic argument.
That means, visEditorRef.current
is mutable with such a type.
If you'll get rid of union type and leave only the HTMLDivElement
, this will still save possible null
value, but in that case visEditorRef.current
is a read-only property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's exactly why I added it here :) Since the file now behaves slightly different I need to make sure visEditorRef
has a value in the tests, since otherwise it does not run through the initialization phase, so I need it to be a MutualRef object in that case. This seemed for me to be the easiest way.
@@ -41,7 +41,7 @@ export const useVisByValue = ( | |||
useEffect(() => { | |||
const { chrome } = services; | |||
const getVisInstance = async () => { | |||
if (!valueInput || loaded.current) { | |||
if (!valueInput || loaded.current || !visEditorRef.current) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ThomThomson Could you check if this is still working as expected? This should not break things theoretically, because the Editor
would anyway not have worked if there was no HTML element passed into, just want to double check.
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanx Tim 🙂
💚 Build SucceededMetrics [docs]@kbn/optimizer bundle module count
async chunks size
page load bundle size
History
To update your PR or re-run it, just comment with: |
* Improve vis editor typings * Move VisEditorContructor to visualize * Fix tests * Fix typings Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
* upstream/master: (34 commits) Improve vis editor typings (elastic#80004) Line Visualization improper scaling can result in gaps elastic#79663 (elastic#80135) [Security Solution][Timeline] Fix SelectableTimeline search (elastic#80128) move field_mapping util to saved_objects plugin (elastic#79918) [ML] Datagrid: Ensure column content with 'boolean' schema is not capitalized (elastic#80041) [CI] Correctly resolve repository root for JUnit reports (elastic#80226) [Ingest Manager] Fix package upgrade breaking after first rollover before new data has arrived (elastic#79887) [Security Solution] Fix positioning of Kibana banners list inside Sec… (elastic#80124) add missing await to fix test (elastic#80202) Revert test data changed in previous commit. (elastic#79479) [Security Solution] [Sourcerer] Jest beef up (elastic#79907) Re-enable transaction duration alert story (elastic#80187) [npm] remove canvas dep (elastic#80185) [DOCS] Redirects ILM docs to Elasticsearch reference (elastic#79798) [APM] Catch health status error from ML (elastic#80131) Fix layout and remove title for add alert popover. (elastic#77633) [Discover] Loading spinner cleanup (elastic#79819) [Security Solution] [Resolver] Remove related events api (elastic#79036) [Ingest Manager] Remove fields from index pattern during package uninstall (elastic#80082) do not refetch license if signature header absents from a response (elastic#79645) ...
* Improve vis editor typings * Move VisEditorContructor to visualize * Fix tests * Fix typings Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
This improves the typings of the
VisType.editor
key.There should be no functional change introduced by this PR.
Checklist
Delete any items that are not applicable to this PR.
For maintainers