diff --git a/web-console/src/components/json-input/json-input.tsx b/web-console/src/components/json-input/json-input.tsx index f1dd512ac17..eba062091d5 100644 --- a/web-console/src/components/json-input/json-input.tsx +++ b/web-console/src/components/json-input/json-input.tsx @@ -80,12 +80,11 @@ export const JsonInput = React.memo(function JsonInput(props: JsonInputProps) { const aceEditor = useRef(); useEffect(() => { - if (!deepEqual(value, internalValue.value)) { - setInternalValue({ - value, - stringified: stringifyJson(value), - }); - } + if (deepEqual(value, internalValue.value)) return; + setInternalValue({ + value, + stringified: stringifyJson(value), + }); }, [value]); const internalValueError = internalValue.error; @@ -149,8 +148,8 @@ export const JsonInput = React.memo(function JsonInput(props: JsonInputProps) { const rc = extractRowColumnFromHjsonError(internalValueError); if (!rc) return; + aceEditor.current.focus(); // Grab the focus aceEditor.current.getSelection().moveCursorTo(rc.row, rc.column); - aceEditor.current.focus(); // Grab the focus also }} > {internalValueError.message} diff --git a/web-console/src/components/more-button/more-button.tsx b/web-console/src/components/more-button/more-button.tsx index 7a161b7e497..4bcef07225f 100644 --- a/web-console/src/components/more-button/more-button.tsx +++ b/web-console/src/components/more-button/more-button.tsx @@ -18,14 +18,19 @@ import { Button, Menu, Popover, Position } from '@blueprintjs/core'; import { IconNames } from '@blueprintjs/icons'; -import React from 'react'; +import React, { useState } from 'react'; + +type OpenState = 'open' | 'alt-open'; export interface MoreButtonProps { - children: React.ReactNode; + children: React.ReactNode | React.ReactNode[]; + altExtra?: React.ReactNode; } export const MoreButton = React.memo(function MoreButton(props: MoreButtonProps) { - const { children } = props; + const { children, altExtra } = props; + + const [openState, setOpenState] = useState(); let childCount = 0; // Sadly React.Children.count does not ignore nulls correctly @@ -36,8 +41,18 @@ export const MoreButton = React.memo(function MoreButton(props: MoreButtonProps) return ( {children}} + isOpen={Boolean(openState)} + content={ + + {children} + {openState === 'alt-open' && altExtra} + + } position={Position.BOTTOM_LEFT} + onInteraction={(nextOpenState, e: any) => { + if (!e) return; // For some reason this function is always called twice once with e and once without + setOpenState(nextOpenState ? (e.altKey ? 'alt-open' : 'open') : undefined); + }} >