mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Lens] Label placeholder always defaults to the lens proposed text (#124222)
* [Lens] Label placeholder always defaults to the lens proposed text * Fix bug
This commit is contained in:
parent
fd0e1aed0e
commit
a5ee534bad
3 changed files with 11 additions and 3 deletions
|
@ -638,7 +638,6 @@ export function DimensionEditor(props: DimensionEditorProps) {
|
|||
() =>
|
||||
String(
|
||||
selectedColumn &&
|
||||
!selectedColumn.customLabel &&
|
||||
operationDefinitionMap[selectedColumn.operationType].getDefaultLabel(
|
||||
selectedColumn,
|
||||
state.indexPatterns[state.layers[layerId].indexPatternId],
|
||||
|
@ -767,6 +766,7 @@ export function DimensionEditor(props: DimensionEditorProps) {
|
|||
// re-render the input from scratch to obtain new "initial value" if the underlying default label changes
|
||||
key={defaultLabel}
|
||||
value={selectedColumn.label}
|
||||
defaultValue={defaultLabel}
|
||||
onChange={(value) => {
|
||||
updateLayer({
|
||||
columns: {
|
||||
|
|
|
@ -33,11 +33,17 @@ export function isQuickFunction(operationType: string) {
|
|||
export const LabelInput = ({
|
||||
value,
|
||||
onChange,
|
||||
defaultValue,
|
||||
}: {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
defaultValue?: string;
|
||||
}) => {
|
||||
const { inputValue, handleInputChange, initialValue } = useDebouncedValue({ onChange, value });
|
||||
const { inputValue, handleInputChange, initialValue } = useDebouncedValue({
|
||||
onChange,
|
||||
value,
|
||||
defaultValue,
|
||||
});
|
||||
|
||||
return (
|
||||
<EuiFormRow
|
||||
|
|
|
@ -21,9 +21,11 @@ export const useDebouncedValue = <T>(
|
|||
{
|
||||
onChange,
|
||||
value,
|
||||
defaultValue,
|
||||
}: {
|
||||
onChange: (val: T) => void;
|
||||
value: T;
|
||||
defaultValue?: T;
|
||||
},
|
||||
{ allowFalsyValue }: { allowFalsyValue?: boolean } = {}
|
||||
) => {
|
||||
|
@ -32,7 +34,7 @@ export const useDebouncedValue = <T>(
|
|||
const shouldUpdateWithFalsyValue = Boolean(allowFalsyValue);
|
||||
|
||||
// Save the initial value
|
||||
const initialValue = useRef(value);
|
||||
const initialValue = useRef(defaultValue ?? value);
|
||||
|
||||
const flushChangesTimeout = useRef<NodeJS.Timeout | undefined>();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue