Skip to content

Commit d08b84d

Browse files
authored
Allow to pass in boolean to preventEnterSubmit directive (#8639)
* Pass in value to preventEnterSubmit directive * Set enabled similar to preventDefault and preventEnterSubmit directives * Update prevent enter submit value * Init value from controller * Use a different default input id prefix for umb-search-filter * Fix typo * Check for truthly value * Revert "Set enabled similar to preventDefault and preventEnterSubmit directives" This reverts commit 536ce85. * None pointer events when clicking icon * Use color variable
1 parent e7ce6a3 commit d08b84d

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

src/Umbraco.Web.UI.Client/src/common/directives/components/forms/prevententersubmit.directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ angular.module("umbraco.directives")
1717
}
1818

1919
$(element).on("keypress", function (event) {
20-
if (event.which === 13) {
20+
if (event.which === 13 && enabled === true) {
2121
event.preventDefault();
2222
}
2323
});

src/Umbraco.Web.UI.Client/src/common/directives/components/forms/umbsearchfilter.directive.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
@param {boolean} model Set to <code>true</code> or <code>false</code> to set the checkbox to checked or unchecked.
2525
@param {string} inputId Set the <code>id</code> of the checkbox.
2626
@param {string} text Set the text for the checkbox label.
27-
@param {string} labelKey Set a dictinary/localization string for the checkbox label
27+
@param {string} labelKey Set a dictionary/localization string for the checkbox label
2828
@param {callback} onChange Callback when the value of the checkbox change by interaction.
2929
@param {boolean} autoFocus Add autofocus to the input field
3030
@param {boolean} preventSubmitOnEnter Set the enter prevent directive or not
@@ -42,13 +42,15 @@
4242
vm.change = change;
4343

4444
function onInit() {
45-
vm.inputId = vm.inputId || "umb-check_" + String.CreateGuid();
45+
vm.inputId = vm.inputId || "umb-search-filter_" + String.CreateGuid();
46+
vm.autoFocus = Object.toBoolean(vm.autoFocus) === true;
47+
vm.preventSubmitOnEnter = Object.toBoolean(vm.preventSubmitOnEnter) === true;
4648

4749
// If a labelKey is passed let's update the returned text if it's does not contain an opening square bracket [
4850
if (vm.labelKey) {
4951
localizationService.localize(vm.labelKey).then(function (data) {
50-
if(data.indexOf('[') === -1){
51-
vm.text = data;
52+
if (data.indexOf('[') === -1){
53+
vm.text = data;
5254
}
5355
});
5456
}

src/Umbraco.Web.UI.Client/src/less/components/umb-search-filter.less

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ html .umb-search-filter {
2121
// "icon-search" class it kept for backward compatibility
2222
.umb-icon,
2323
.icon-search {
24-
color: #d8d7d9;
24+
color: @gray-8;
2525
position: absolute;
2626
top: 0;
2727
bottom: 0;
2828
left: 10px;
2929
margin: auto 0;
30+
pointer-events: none;
3031
}
3132
}

src/Umbraco.Web.UI.Client/src/views/components/forms/umb-search-filter.html

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,14 @@
22
<div class="umb-search-filter" ng-class="vm.cssClass">
33
<label for="{{vm.inputId}}" class="sr-only">{{vm.text}}</label>
44
<umb-icon icon="icon-search" class="icon-search"></umb-icon>
5-
<input
6-
ng-if="vm.preventSubmitOnEnter"
7-
id="{{vm.inputId}}"
8-
type="text"
9-
ng-change="vm.change()"
10-
ng-model="vm.model"
11-
class="umb-search-filter__input"
12-
placeholder="{{vm.text}}"
13-
umb-auto-focus="{{vm.autoFocus === true}}"
14-
prevent-enter-submit
15-
no-dirty-check />
16-
17-
<input
18-
ng-if="!vm.preventSubmitOnEnter"
19-
id="{{vm.inputId}}"
20-
type="text"
21-
ng-change="vm.change()"
22-
ng-model="vm.model"
23-
class="umb-search-filter__input {{vm.cssClass}}"
24-
placeholder="{{vm.text}}"
25-
umb-auto-focus="{{vm.autoFocus === true}}"
26-
no-dirty-check />
5+
<input type="text"
6+
id="{{vm.inputId}}"
7+
ng-change="vm.change()"
8+
ng-model="vm.model"
9+
class="umb-search-filter__input"
10+
placeholder="{{vm.text}}"
11+
umb-auto-focus="{{vm.autoFocus}}"
12+
prevent-enter-submit="{{vm.preventSubmitOnEnter}}"
13+
no-dirty-check />
2714
</div>
2815
</div>

0 commit comments

Comments
 (0)