Browse Source

Fixed the Add widget dialog ignoring clicks after pressing Enter in a settings field (#16838)

* Fixed widget config dialog freezing on Enter: add type="button" to non-submit buttons

* Fixed Enter in widget config fields triggering Add/Preview: add type="button" and a disabled default submit button to widget config forms

* Merge fixes

* Fixed license headers

* Apply suggestion from @vvlladd28

---------

Co-authored-by: Vladyslav Prykhodko <vprykhodko@thingsboard.io>
pull/16860/head
Maksym Tsymbarov 3 days ago
committed by GitHub
parent
commit
aec8141336
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      ui-ngx/src/app/modules/home/components/alarm/alarm-filter-config.component.html
  2. 4
      ui-ngx/src/app/modules/home/components/dashboard-page/add-widget-dialog.component.html
  3. 9
      ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.html
  4. 2
      ui-ngx/src/app/modules/home/components/widget/config/basic/alarm/alarm-count-basic-config.component.html
  5. 2
      ui-ngx/src/app/modules/home/components/widget/config/basic/alarm/alarms-table-basic-config.component.html
  6. 7
      ui-ngx/src/app/modules/home/components/widget/config/basic/common/widget-actions-panel.component.html
  7. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/custom-action-pretty-editor.component.html
  8. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style.component.html
  9. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-toggle-custom-style.component.html
  10. 2
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.html
  11. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/date-format-select.component.html
  12. 7
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.html
  13. 9
      ui-ngx/src/app/modules/home/components/widget/lib/settings/common/html/html-container-settings.component.html
  14. 2
      ui-ngx/src/app/modules/home/components/widget/widget-config.component.html
  15. 5
      ui-ngx/src/app/shared/components/json-object-edit.component.html

1
ui-ngx/src/app/modules/home/components/alarm/alarm-filter-config.component.html

@ -13,6 +13,7 @@
matTooltip="{{buttonDisplayValue}}"
matTooltipPosition="above"
mat-stroked-button
type="button"
(click)="toggleAlarmFilterPanel($event)">
<mat-icon>filter_list</mat-icon>{{buttonDisplayValue}}
</button>

4
ui-ngx/src/app/modules/home/components/dashboard-page/add-widget-dialog.component.html

@ -6,6 +6,8 @@
-->
<form class="tb-add-widget-dialog" [formGroup]="widgetFormGroup">
<!-- Disabled default button: stops Enter in a field from submitting the form -->
<button type="submit" disabled hidden></button>
<mat-toolbar color="tb-primary" class="tb-bottom-border">
<div class="tb-add-widget-toolbar">
<h2>{{'widget.add' | translate}}:</h2>
@ -52,6 +54,7 @@
[previewHeight]="widgetConfig.typeParameters.previewHeight">
<div class="tb-preview-panel-content">
<button mat-button
type="button"
(click)="previewMode = false">
<mat-icon>chevron_left</mat-icon>
{{ 'action.back' | translate }}
@ -79,6 +82,7 @@
</button>
}
<button mat-raised-button color="primary"
type="button"
(click)="add()"
[disabled]="!widgetFormGroup.valid">
{{ 'action.add' | translate }}

9
ui-ngx/src/app/modules/home/components/dashboard-page/edit-widget.component.html

@ -1,10 +1,12 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<form [formGroup]="widgetFormGroup">
<button type="submit" disabled hidden aria-hidden="true"></button>
<fieldset [disabled]="isLoading$ | async">
<tb-widget-config
#widgetConfigComponent
@ -19,6 +21,7 @@
<div class="tb-widget-config-header-prefix">
@if (previewMode) {
<button mat-button
type="button"
(click)="previewMode = false">
<mat-icon>chevron_left</mat-icon>
{{ 'action.back' | translate }}
@ -29,6 +32,7 @@
class="gt-sm:!hidden"
[disabled]="!widgetFormGroup.valid"
mat-button color="primary"
type="button"
(click)="previewMode = true">
<mat-icon>visibility</mat-icon>
{{ 'widget-config.preview' | translate }}
@ -41,6 +45,7 @@
class="lt-md:!hidden"
[disabled]="!widgetFormGroup.valid"
mat-button color="primary"
type="button"
(click)="previewMode = true">
<mat-icon>visibility</mat-icon>
{{ 'widget-config.preview' | translate }}
@ -49,12 +54,14 @@
<div class="flex flex-row items-center justify-start gap-3">
<button [disabled]="!widgetFormGroup.dirty"
mat-stroked-button color="primary"
type="button"
(click)="onRevertWidgetConfig()">
<mat-icon>close</mat-icon>
{{ 'action.decline' | translate }}
</button>
<button [disabled]="!widgetFormGroup.valid || !widgetFormGroup.dirty"
mat-flat-button color="primary"
type="button"
(click)="onApplyWidgetConfig()">
<mat-icon>done</mat-icon>
{{ 'action.apply' | translate }}

2
ui-ngx/src/app/modules/home/components/widget/config/basic/alarm/alarm-count-basic-config.component.html

@ -18,7 +18,7 @@
<div class="tb-form-panel">
<div class="flex flex-row items-center justify-between">
<div class="tb-form-panel-title" translate>alarm.filter</div>
<button mat-button color="primary"
<button type="button" mat-button color="primary"
(click)="alarmFilterConfig.reset()">
{{ 'action.reset' | translate }}
</button>

2
ui-ngx/src/app/modules/home/components/widget/config/basic/alarm/alarms-table-basic-config.component.html

@ -16,7 +16,7 @@
<div class="tb-form-panel">
<div class="flex flex-row items-center justify-between">
<div class="tb-form-panel-title" translate>alarm.filter</div>
<button mat-button color="primary"
<button type="button" mat-button color="primary"
(click)="alarmFilterConfig.reset()">
{{ 'action.reset' | translate }}
</button>

7
ui-ngx/src/app/modules/home/components/widget/config/basic/common/widget-actions-panel.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-form-panel" [class.stroked]="strokedPanel" (click)="manageWidgetActions()" style="cursor: pointer;">
@ -18,12 +19,12 @@
}
</mat-chip-listbox>
@if (!hasWidgetActions) {
<button mat-stroked-button color="primary">
<button type="button" mat-stroked-button color="primary">
{{ 'widget-config.add-action' | translate }}
</button>
}
@if (hasWidgetActions) {
<button mat-icon-button color="primary">
<button type="button" mat-icon-button color="primary">
<mat-icon>add</mat-icon>
</button>
}

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/action/custom-action-pretty-editor.component.html

@ -1,13 +1,14 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-custom-action-pretty" tb-fullscreen [fullscreen]="fullscreen">
<div class="tb-action-expand-button flex flex-row items-center justify-end" [class.tb-fullscreen-editor]="fullscreen">
@if (!fullscreen) {
<button
<button type="button"
class="lt-md:!hidden"
mat-icon-button
matTooltip="{{ 'widget.toggle-fullscreen' | translate }}"
@ -17,7 +18,7 @@
</button>
}
@if (fullscreen) {
<button
<button type="button"
mat-button
matTooltip="{{ 'widget.toggle-fullscreen' | translate }}"
matTooltipPosition="above"

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-custom-style.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-widget-button-custom-style">
@ -17,7 +18,7 @@
[disabled]="state === widgetButtonState.disabled">
</tb-widget-button>
@if (modelValue) {
<button
<button type="button"
mat-icon-button
[matTooltip]="'widgets.button.clear-style' | translate"
matTooltipPosition="above"
@ -27,7 +28,7 @@
</button>
}
</div>
<button mat-icon-button
<button type="button" mat-icon-button
class="tb-mat-32"
#matIconButton
(click)="openButtonCustomStylePopup($event, matIconButton)">

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/button/widget-button-toggle-custom-style.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-widget-button-custom-style">
@ -16,7 +17,7 @@
[disabled]="state === widgetButtonToggleState.disabled">
</tb-widget-button-toggle>
@if (modelValue) {
<button
<button type="button"
mat-icon-button
[matTooltip]="'widgets.button.clear-style' | translate"
matTooltipPosition="above"
@ -26,7 +27,7 @@
</button>
}
</div>
<button mat-icon-button
<button type="button" mat-icon-button
class="tb-mat-32"
#matIconButton
(click)="openButtonCustomStylePopup($event, matIconButton)">

2
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/color-range-list.component.html

@ -98,7 +98,7 @@
}
</div>
<div class="tb-add-color-range">
<button mat-stroked-button
<button type="button" mat-stroked-button
(click)="addRange()">
<mat-icon>add</mat-icon>
</button>

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/date-format-select.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<mat-form-field appearance="outline" subscriptSizing="dynamic" style="width: 100%;">
@ -11,13 +12,13 @@
}
</mat-select>
@if (dateFormatFormControl.value?.custom) {
<button #customFormatButton
<button type="button" #customFormatButton
matSuffix mat-icon-button (click)="openDateFormatSettingsPopup($event, customFormatButton)">
<tb-icon>edit</tb-icon>
</button>
}
@if (dateFormatFormControl.value?.auto && !dateFormatFormControl.value?.custom) {
<button #autoFormatButton
<button type="button" #autoFormatButton
matSuffix mat-icon-button (click)="openAutoFormatSettingsPopup($event, autoFormatButton)">
<tb-icon>edit</tb-icon>
</button>

7
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/gradient.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<ng-container [formGroup]="gradientFormGroup">
@ -83,7 +84,7 @@
</div>
</div>
}
<button class="tb-add-gradient"
<button type="button" class="tb-add-gradient"
mat-stroked-button
(click)="addGradient()">
<mat-icon>add</mat-icon>
@ -175,7 +176,7 @@
</div>
</div>
}
<button class="tb-add-gradient"
<button type="button" class="tb-add-gradient"
mat-stroked-button
(click)="addGradient(true)">
<mat-icon>add</mat-icon>

9
ui-ngx/src/app/modules/home/components/widget/lib/settings/common/html/html-container-settings.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<ng-container [formGroup]="htmlContainerSettingsForm">
@ -14,7 +15,7 @@
</div>
<div class="tb-html-container-settings-panel flex flex-1 flex-col" tb-fullscreen [fullscreen]="fullscreen">
<div class="tb-action-expand-button flex flex-row items-center justify-end">
<button mat-stroked-button
<button type="button" mat-stroked-button
matTooltip="{{ 'widget.toggle-fullscreen' | translate }}"
matTooltipPosition="above"
(click)="toggleFullScreen()">
@ -51,7 +52,7 @@
{{ 'widget.resource-is-extension' | translate }}
</mat-checkbox>
}
<button mat-icon-button color="primary"
<button type="button" mat-icon-button color="primary"
(click)="removeResource(i)"
matTooltip="{{'widget.remove-resource' | translate}}"
matTooltipPosition="above">
@ -64,7 +65,7 @@
class="tb-prompt flex items-center justify-center">widgets.html-container.no-resources</span>
}
<div>
<button mat-raised-button color="primary"
<button type="button" mat-raised-button color="primary"
(click)="addResource()"
matTooltip="{{'widget.add-resource' | translate}}"
matTooltipPosition="above">

2
ui-ngx/src/app/modules/home/components/widget/widget-config.component.html

@ -272,7 +272,7 @@
<div [formGroup]="dataSettings" class="tb-form-panel">
<div class="flex flex-row items-center justify-between">
<div class="tb-form-panel-title" translate>alarm.filter</div>
<button mat-button color="primary"
<button type="button" mat-button color="primary"
(click)="alarmFilterConfig.reset()">
{{ 'action.reset' | translate }}
</button>

5
ui-ngx/src/app/shared/components/json-object-edit.component.html

@ -1,7 +1,8 @@
<!--
SPDX-FileCopyrightText: Copyright The ThingsBoard Authors
SPDX-License-Identifier: Apache-2.0
SPDX-FileCopyrightText: Modifications Copyright ThingsBoard, Inc.
SPDX-License-Identifier: Apache-2.0 AND BUSL-1.1
-->
<div class="tb-json-object flex flex-col" style="background: #fff;" [class.fill-height]="fillHeight"
@ -26,7 +27,7 @@
</button>
}
<ng-content select="[toolbarSuffixButton]"></ng-content>
<button mat-icon-button class="tb-mat-32" (click)="fullscreen = !fullscreen"
<button mat-icon-button class="tb-mat-32" type="button" (click)="fullscreen = !fullscreen"
matTooltip="{{(fullscreen ? 'fullscreen.exit' : 'fullscreen.expand') | translate}}"
matTooltipPosition="above">
<mat-icon class="material-icons">{{ fullscreen ? 'fullscreen_exit' : 'fullscreen' }}</mat-icon>

Loading…
Cancel
Save