mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: invalid handling disabled={false} causing app crash
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
77ae31550a
commit
fb66423d4b
@ -53,10 +53,13 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
|
|||||||
render() {
|
render() {
|
||||||
const { disabled, className } = this.props;
|
const { disabled, className } = this.props;
|
||||||
const { onDragEnter, onDragLeave, onDragOver, onDrop } = this;
|
const { onDragEnter, onDragLeave, onDragOver, onDrop } = this;
|
||||||
|
const contentElem = React.Children.only(this.props.children) as React.ReactElement<React.HTMLProps<HTMLElement>>;
|
||||||
|
if (disabled) {
|
||||||
|
return contentElem;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const contentElem = React.Children.only(this.props.children) as React.ReactElement<React.HTMLProps<HTMLElement>>;
|
|
||||||
const isValidContentElem = React.isValidElement(contentElem);
|
const isValidContentElem = React.isValidElement(contentElem);
|
||||||
if (!disabled && isValidContentElem) {
|
if (isValidContentElem) {
|
||||||
const contentElemProps: React.HTMLProps<HTMLElement> = {
|
const contentElemProps: React.HTMLProps<HTMLElement> = {
|
||||||
className: cssNames("DropFileInput", className, {
|
className: cssNames("DropFileInput", className, {
|
||||||
droppable: this.dropAreaActive,
|
droppable: this.dropAreaActive,
|
||||||
@ -70,7 +73,7 @@ export class DropFileInput<T extends HTMLElement = any> extends React.Component<
|
|||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error("Invalid root content-element for DropFileInput", { err: String(err) });
|
logger.error("Invalid root content-element for DropFileInput", { err: String(err) });
|
||||||
return this.props.children;
|
return contentElem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user