diff --git a/packages/grafana-ui/src/components/TagsInput/TagsInput.tsx b/packages/grafana-ui/src/components/TagsInput/TagsInput.tsx index 5e1246e09a3..017b1bc8364 100644 --- a/packages/grafana-ui/src/components/TagsInput/TagsInput.tsx +++ b/packages/grafana-ui/src/components/TagsInput/TagsInput.tsx @@ -85,6 +85,13 @@ export const TagsInput: FC = ({ onChange={onNameChange} value={newTagName} onKeyUp={onKeyboardAdd} + onKeyDown={(e) => { + // onKeyDown is triggered before onKeyUp, triggering submit behaviour on Enter press if this component + // is used inside forms. Moving onKeyboardAdd callback here doesn't work since text input is not captured in onKeyDown + if (e.key === 'Enter') { + e.preventDefault(); + } + }} onBlur={onBlur} invalid={invalid} suffix={