diff --git a/frontend/src/__tests__/cypress/cypress/tests/mocked/pipelines/pipelineCreateRuns.cy.ts b/frontend/src/__tests__/cypress/cypress/tests/mocked/pipelines/pipelineCreateRuns.cy.ts index 7d361cf97d..4e270a2e84 100644 --- a/frontend/src/__tests__/cypress/cypress/tests/mocked/pipelines/pipelineCreateRuns.cy.ts +++ b/frontend/src/__tests__/cypress/cypress/tests/mocked/pipelines/pipelineCreateRuns.cy.ts @@ -267,7 +267,7 @@ describe('Pipeline create runs', () => { }, double_param: { parameterType: InputDefinitionParameterType.DOUBLE, - defaultValue: 0.1, + defaultValue: 7.0, description: 'Some double helper text', isOptional: true, }, @@ -313,7 +313,7 @@ describe('Pipeline create runs', () => { paramsSection.findParamById('string_param').should('have.value', 'String default value'); cy.findByTestId('string_param-helper-text').should('have.text', 'Some string helper text'); - paramsSection.findParamById('double_param').should('have.value', '0.1'); + paramsSection.findParamById('double_param').should('have.value', '7.0'); cy.findByTestId('double_param-form-group').should('not.have.text', '*', { exact: false }); cy.findByTestId('double_param-helper-text').should('have.text', 'Some double helper text'); diff --git a/frontend/src/concepts/pipelines/content/createRun/contentSections/ParamsSection/NumberInputParam.tsx b/frontend/src/concepts/pipelines/content/createRun/contentSections/ParamsSection/NumberInputParam.tsx index 04d1b98a6f..fb44f00307 100644 --- a/frontend/src/concepts/pipelines/content/createRun/contentSections/ParamsSection/NumberInputParam.tsx +++ b/frontend/src/concepts/pipelines/content/createRun/contentSections/ParamsSection/NumberInputParam.tsx @@ -1,5 +1,5 @@ import { TextInput } from '@patternfly/react-core'; -import React from 'react'; +import React, { useRef } from 'react'; import NumberInputWrapper from '~/components/NumberInputWrapper'; import { InputParamProps } from './types'; @@ -15,16 +15,24 @@ export const NumberInputParam: React.FC = ({ const [value, setValue] = React.useState( inputProps.value !== '' ? Number(inputProps.value) : '', ); + const isDefault = useRef(true); if (isFloat) { + // if the default value is a whole number, display it as x.0 + const displayValue = + typeof value === 'number' && Number.isInteger(value) && isDefault.current + ? value.toFixed(1) + : value; + return ( { + isDefault.current = false; setValue(typeof newValue === 'string' ? parseFloat(newValue) : newValue); onChange(event, newValue); }} diff --git a/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/SelectedNodeInputOutputTab.tsx b/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/SelectedNodeInputOutputTab.tsx index 3bd6701fc4..6ba2dec35d 100644 --- a/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/SelectedNodeInputOutputTab.tsx +++ b/frontend/src/concepts/pipelines/content/pipelinesDetails/pipelineRun/SelectedNodeInputOutputTab.tsx @@ -48,6 +48,9 @@ const SelectedNodeInputOutputTab: React.FC = ({ switch (type) { case InputDefinitionParameterType.DOUBLE: + return numberValue && Number.isInteger(numberValue) + ? numberValue.toFixed(1) + : numberValue; case InputDefinitionParameterType.INTEGER: return numberValue; case InputDefinitionParameterType.BOOLEAN: