-
Notifications
You must be signed in to change notification settings - Fork 172
Implement forceSelection attribute #240
base: dev
Are you sure you want to change the base?
Changes from 5 commits
79dc66f
cb1bc71
114add0
1237623
38b7ce0
985b5a1
1906f9e
5d8bc3f
eca9e20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<div class="completer-holder" ctrCompleter> | ||
<md-input-container class="completer-input"> | ||
<input mdInput ctrInput="clearSelected=clearSelected; overrideSuggested=overrideSuggested; fillHighlighted=fillHighlighted" [(ngModel)]="searchStr" | ||
<input mdInput ctrInput="clearSelected=clearSelected; overrideSuggested=overrideSuggested; fillHighlighted=fillHighlighted; forceSelection=forceSelection" [(ngModel)]="searchStr" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it'll be better to change one of the |
||
[attr.name]="inputName" [attr.maxlength]="maxChars" [tabindex]="fieldTabindex" [disabled]="disableInput" (blur)="onBlur()" [placeholder]="placeholder" | ||
autocomplete="off" autocorrect="off" autocapitalize="off"> | ||
</md-input-container> | ||
|
@@ -25,4 +25,4 @@ | |
</md-list-item> | ||
</md-list> | ||
</div> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,6 +135,7 @@ export class CompleterCmp implements OnInit, ControlValueAccessor, AfterViewChec | |
@Input() public openOnFocus = false; | ||
@Input() public initialValue: any; | ||
@Input() public autoHighlight = false; | ||
@Input() public forceSelection = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made a confusion thinking completer-cmp-md.html was the template. I was rushing at that time ×) |
||
|
||
@Output() public selected = new EventEmitter<CompleterItem>(); | ||
@Output() public highlighted = new EventEmitter<CompleterItem>(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ export class CtrInput { | |
@Input("overrideSuggested") public overrideSuggested = false; | ||
@Input("fillHighlighted") public fillHighlighted = true; | ||
@Input("openOnFocus") public openOnFocus = false; | ||
@Input("forceSelection") public forceSelection = false; | ||
|
||
@Output() public ngModelChange: EventEmitter<any> = new EventEmitter(); | ||
|
||
|
@@ -99,7 +100,9 @@ export class CtrInput { | |
if (this.completer.hasHighlighted()) { | ||
event.preventDefault(); | ||
} | ||
this.handleSelection(); | ||
if (!this.forceSelection || this.completer._hasHighlighted) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the check can be done inside There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not remember precisely what I was trying to do with the TAB, I guess maybe leaving the menu opened on TAB but this would prevent from switching to a next input in the form, which is pretty much what should happen. Otherwise you need to tqke your mouse to leave the field, and would be some kind of autofocus on TAB. So I guess only ENTER key should be concerned. |
||
this.handleSelection(); | ||
} | ||
} else if (event.keyCode === KEY_DW) { | ||
event.preventDefault(); | ||
this.completer.open(); | ||
|
@@ -108,7 +111,9 @@ export class CtrInput { | |
event.preventDefault(); | ||
this.completer.prevRow(); | ||
} else if (event.keyCode === KEY_TAB) { | ||
this.handleSelection(); | ||
if (!this.forceSelection || this.completer._hasHighlighted) { | ||
this.handleSelection(); | ||
} | ||
} else if (event.keyCode === KEY_ES) { | ||
// This is very specific to IE10/11 #272 | ||
// without this, IE clears the input text | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default should be
false