Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default function PolicyParameterSelectorValueSetter({
setStartDate,
endDate,
setEndDate,
onEnter: handleSubmit,
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function DateValueSelector(props: ValueSetterProps) {
setStartDate,
endDate,
setEndDate,
onEnter,
} = props;

// Local state for param value
Expand Down Expand Up @@ -87,7 +88,7 @@ export function DateValueSelector(props: ValueSetterProps) {
onChange={handleEndDateChange}
/>
</div>
<ValueInputBox param={param} value={paramValue} onChange={setParamValue} />
<ValueInputBox param={param} value={paramValue} onChange={setParamValue} onEnter={onEnter} />
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function DefaultValueSelector(props: ValueSetterProps) {
setStartDate,
endDate,
setEndDate,
onEnter,
} = props;

// Local state for param value
Expand Down Expand Up @@ -80,7 +81,12 @@ export function DefaultValueSelector(props: ValueSetterProps) {
<span className="tw:text-sm tw:font-medium">onward:</span>
</div>
<div className="tw:flex-1">
<ValueInputBox param={param} value={paramValue} onChange={setParamValue} />
<ValueInputBox
param={param}
value={paramValue}
onChange={setParamValue}
onEnter={onEnter}
/>
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ValueInputBox } from './ValueInputBox';
import { ValueSetterProps } from './ValueSetterProps';

export function MultiYearValueSelector(props: ValueSetterProps) {
const { param, policy, setIntervals } = props;
const { param, policy, setIntervals, onEnter } = props;

// Get available years from metadata
const availableYears = useSelector(getTaxYears);
Expand Down Expand Up @@ -87,6 +87,7 @@ export function MultiYearValueSelector(props: ValueSetterProps) {
param={param}
value={yearValues[year]}
onChange={(value) => handleYearValueChange(year, value)}
onEnter={onEnter}
/>
</div>
))}
Expand All @@ -101,6 +102,7 @@ export function MultiYearValueSelector(props: ValueSetterProps) {
param={param}
value={yearValues[year]}
onChange={(value) => handleYearValueChange(year, value)}
onEnter={onEnter}
/>
</div>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ interface ValueInputBoxProps {
param: ParameterMetadata;
value?: any;
onChange?: (value: any) => void;
onEnter?: () => void;
}

export function ValueInputBox(props: ValueInputBoxProps) {
const { param, value, onChange, label } = props;
const { param, value, onChange, onEnter, label } = props;

// US and UK packages use these type designations inconsistently
const USD_UNITS = ['currency-USD', 'currency_USD', 'USD'];
Expand Down Expand Up @@ -98,6 +99,12 @@ export function ValueInputBox(props: ValueInputBoxProps) {
value={displayValue}
onChange={handleChange}
className={cn(prefix ? 'tw:pl-7' : '', isPercentage ? 'tw:pr-7' : '')}
onKeyDown={(event) => {
if (event.key === 'Enter') {
event.preventDefault();
onEnter?.();
}
}}
style={{ flex: 1 }}
/>
{isPercentage && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export interface ValueSetterProps {
setStartDate: Dispatch<SetStateAction<string>>;
endDate: string;
setEndDate: Dispatch<SetStateAction<string>>;
onEnter?: () => void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function YearlyValueSelector(props: ValueSetterProps) {
setStartDate,
endDate,
setEndDate,
onEnter,
} = props;

// Local state for param value
Expand Down Expand Up @@ -99,7 +100,7 @@ export function YearlyValueSelector(props: ValueSetterProps) {
onChange={handleEndYearChange}
/>
</div>
<ValueInputBox param={param} value={paramValue} onChange={setParamValue} />
<ValueInputBox param={param} value={paramValue} onChange={setParamValue} onEnter={onEnter} />
</div>
);
}