Alerting: Fix enter key 'clicking' first button on form (#55222)

* Add type='button' in button used in Heading component to prevent having the default value ='submit'

* Add type='button' for buttons used in form when grafana-managed alert type is selected

* Add type='button' for buttons used in form when mimir-or-loki alert type is selected
pull/55473/head
Sonia Aguilar 3 years ago committed by GitHub
parent 20e6e0d593
commit 4270e5606c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/grafana-ui/src/components/Card/Card.tsx
  2. 1
      public/app/features/query/components/QueryEditorRowHeader.tsx
  3. 1
      public/app/plugins/datasource/prometheus/components/PromQueryField.tsx

@ -97,7 +97,7 @@ const Heading = ({ children, className, 'aria-label': ariaLabel }: ChildProps &
{children}
</a>
) : onClick ? (
<button onClick={onClick} className={styles.linkHack} aria-label={ariaLabel}>
<button onClick={onClick} className={styles.linkHack} aria-label={ariaLabel} type="button">
{children}
</button>
) : (

@ -91,6 +91,7 @@ export const QueryEditorRowHeader = <TQuery extends DataQuery>(props: Props<TQue
title="Edit query name"
onClick={onEditQuery}
data-testid="query-name-div"
type="button"
>
<span className={styles.queryName}>{query.refId}</span>
<Icon name="pen" className={styles.queryEditIcon} size="sm" />

@ -297,6 +297,7 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
className="gf-form-label query-keyword pointer"
onClick={this.onClickChooserButton}
disabled={buttonDisabled}
type="button"
>
{chooserText}
<Icon name={labelBrowserVisible ? 'angle-down' : 'angle-right'} />

Loading…
Cancel
Save