Skip to content

Commit

Permalink
Mark an internal prop of the React wrapper's base editor component as…
Browse files Browse the repository at this point in the history
… optional. (#10429)

* - Mark the 'editorColumnScope' in the base editor component as optional
- Make the 'editorColumnScope' types more precise

* Add the changelog entry.
  • Loading branch information
jansiegel committed Jun 28, 2023
1 parent 2b3d6d8 commit 9c268d8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
8 changes: 8 additions & 0 deletions .changelogs/10429.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"issuesOrigin": "public",
"title": "Mark an internal prop of the React wrapper's base editor component as optional.",
"type": "fixed",
"issueOrPR": 10429,
"breaking": false,
"framework": "react"
}
6 changes: 3 additions & 3 deletions wrappers/react/src/baseEditorComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import Handsontable from 'handsontable/base';
import { HotEditorProps } from './types';
import { EditorScopeIdentifier, HotEditorProps } from './types';

interface BaseEditorProps extends HotEditorProps {
editorColumnScope: number;
emitEditorInstance?: (editor: BaseEditorComponent, column: number) => void,
editorColumnScope?: EditorScopeIdentifier;
emitEditorInstance?: (editor: BaseEditorComponent, column: EditorScopeIdentifier) => void,
}

class BaseEditorComponent<P = {}, S = {}, SS = any> extends React.Component<P & BaseEditorProps, S, SS> implements Handsontable.editors.BaseEditor {
Expand Down
7 changes: 4 additions & 3 deletions wrappers/react/src/helpers.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import {
EditorScopeIdentifier,
HotEditorCache,
HotEditorElement
} from './types';
Expand Down Expand Up @@ -104,15 +105,15 @@ export function createEditorPortal(doc: Document = document, editorElement: HotE
}

/**
* Get an editor element extended with a instance-emitting method.
* Get an editor element extended with an instance-emitting method.
*
* @param {React.ReactNode} children Component children.
* @param {Map} editorCache Component's editor cache.
* @param {string|number} [editorColumnScope] The editor scope (column index or a 'global' string). Defaults to
* @param {EditorScopeIdentifier} [editorColumnScope] The editor scope (column index or a 'global' string). Defaults to
* 'global'.
* @returns {React.ReactElement} An editor element containing the additional methods.
*/
export function getExtendedEditorElement(children: React.ReactNode, editorCache: HotEditorCache, editorColumnScope: string | number = GLOBAL_EDITOR_SCOPE): React.ReactElement | null {
export function getExtendedEditorElement(children: React.ReactNode, editorCache: HotEditorCache, editorColumnScope: EditorScopeIdentifier = GLOBAL_EDITOR_SCOPE): React.ReactElement | null {
const editorElement = getChildElementByType(children, 'hot-editor');
const editorClass = getOriginalEditorClass(editorElement);

Expand Down

0 comments on commit 9c268d8

Please sign in to comment.