Allow space (key) in Mat-Input inside mat-step












1















I have added a mat-input inside the mat-step's template, so that title can be added by user.



<mat-horizontal-stepper>
<mat-step *ngFor="let group of apprGrpList; let i = index"
[label]="group.group_Name | capitalize"
[editable]="isEditable" >
<ng-template matStepLabel>
<mat-form-field class="sf-form-width">
<input class="sf-form-input"
matInput #title maxlength="30"
placeholder="Aprroval Step Title"
autocomplete="off">
<mat-hint *ngIf="title.value"
align="end">{{title.value.length}} / 30</mat-hint>
<button mat-button *ngIf="title.value"
matSuffix mat-icon-button aria-label="Clear"
(click)="title.value=''">
<mat-icon>close</mat-icon>
</button>
<button mat-button *ngIf="title.value"
matSuffix mat-icon-button aria-label="Set"
(click)="setTitle(group.sequence, title.value)">
<mat-icon>check</mat-icon>
</button>
</mat-form-field>
</ng-template>
...


below is a sample capture of what I have achieved.
enter image description here



Everything works fine until typing a words in mat-input does not accepts space input (spacebar keypress).



Any suggestions how to allow space key in mat-input inside mat-steps?





I have seen this in the documentations, is there a way to by pass SPACE event defaults?



Keyboard interaction




  • LEFT_ARROW: Focuses the previous step header

  • RIGHT_ARROW: Focuses the next step header


  • ENTER, SPACE: Selects the step that the focus is currently on

  • TAB: Focuses the next tabbable element

  • TAB+SHIFT: Focuses the previous tabbable element


https://material.angular.io/components/stepper/overview



https://stackblitz.com/edit/angular-9hm4bv










share|improve this question

























  • what happens currently when the space button is pressed?

    – JBoothUA
    Nov 20 '18 at 6:35











  • @JBoothUA - If I type a word "My Stepper", it display as "MyStepper", no space in between words.

    – M.Laida
    Nov 20 '18 at 6:39













  • I just tried on stackblitz its working fine!

    – Hrishikesh Kale
    Nov 20 '18 at 6:40











  • here is the link angular-wxpesf.stackblitz.io

    – Hrishikesh Kale
    Nov 20 '18 at 6:40






  • 1





    thanks, i think i have a working answer for you

    – JBoothUA
    Nov 21 '18 at 17:42
















1















I have added a mat-input inside the mat-step's template, so that title can be added by user.



<mat-horizontal-stepper>
<mat-step *ngFor="let group of apprGrpList; let i = index"
[label]="group.group_Name | capitalize"
[editable]="isEditable" >
<ng-template matStepLabel>
<mat-form-field class="sf-form-width">
<input class="sf-form-input"
matInput #title maxlength="30"
placeholder="Aprroval Step Title"
autocomplete="off">
<mat-hint *ngIf="title.value"
align="end">{{title.value.length}} / 30</mat-hint>
<button mat-button *ngIf="title.value"
matSuffix mat-icon-button aria-label="Clear"
(click)="title.value=''">
<mat-icon>close</mat-icon>
</button>
<button mat-button *ngIf="title.value"
matSuffix mat-icon-button aria-label="Set"
(click)="setTitle(group.sequence, title.value)">
<mat-icon>check</mat-icon>
</button>
</mat-form-field>
</ng-template>
...


below is a sample capture of what I have achieved.
enter image description here



Everything works fine until typing a words in mat-input does not accepts space input (spacebar keypress).



Any suggestions how to allow space key in mat-input inside mat-steps?





I have seen this in the documentations, is there a way to by pass SPACE event defaults?



Keyboard interaction




  • LEFT_ARROW: Focuses the previous step header

  • RIGHT_ARROW: Focuses the next step header


  • ENTER, SPACE: Selects the step that the focus is currently on

  • TAB: Focuses the next tabbable element

  • TAB+SHIFT: Focuses the previous tabbable element


https://material.angular.io/components/stepper/overview



https://stackblitz.com/edit/angular-9hm4bv










share|improve this question

























  • what happens currently when the space button is pressed?

    – JBoothUA
    Nov 20 '18 at 6:35











  • @JBoothUA - If I type a word "My Stepper", it display as "MyStepper", no space in between words.

    – M.Laida
    Nov 20 '18 at 6:39













  • I just tried on stackblitz its working fine!

    – Hrishikesh Kale
    Nov 20 '18 at 6:40











  • here is the link angular-wxpesf.stackblitz.io

    – Hrishikesh Kale
    Nov 20 '18 at 6:40






  • 1





    thanks, i think i have a working answer for you

    – JBoothUA
    Nov 21 '18 at 17:42














1












1








1








I have added a mat-input inside the mat-step's template, so that title can be added by user.



<mat-horizontal-stepper>
<mat-step *ngFor="let group of apprGrpList; let i = index"
[label]="group.group_Name | capitalize"
[editable]="isEditable" >
<ng-template matStepLabel>
<mat-form-field class="sf-form-width">
<input class="sf-form-input"
matInput #title maxlength="30"
placeholder="Aprroval Step Title"
autocomplete="off">
<mat-hint *ngIf="title.value"
align="end">{{title.value.length}} / 30</mat-hint>
<button mat-button *ngIf="title.value"
matSuffix mat-icon-button aria-label="Clear"
(click)="title.value=''">
<mat-icon>close</mat-icon>
</button>
<button mat-button *ngIf="title.value"
matSuffix mat-icon-button aria-label="Set"
(click)="setTitle(group.sequence, title.value)">
<mat-icon>check</mat-icon>
</button>
</mat-form-field>
</ng-template>
...


below is a sample capture of what I have achieved.
enter image description here



Everything works fine until typing a words in mat-input does not accepts space input (spacebar keypress).



Any suggestions how to allow space key in mat-input inside mat-steps?





I have seen this in the documentations, is there a way to by pass SPACE event defaults?



Keyboard interaction




  • LEFT_ARROW: Focuses the previous step header

  • RIGHT_ARROW: Focuses the next step header


  • ENTER, SPACE: Selects the step that the focus is currently on

  • TAB: Focuses the next tabbable element

  • TAB+SHIFT: Focuses the previous tabbable element


https://material.angular.io/components/stepper/overview



https://stackblitz.com/edit/angular-9hm4bv










share|improve this question
















I have added a mat-input inside the mat-step's template, so that title can be added by user.



<mat-horizontal-stepper>
<mat-step *ngFor="let group of apprGrpList; let i = index"
[label]="group.group_Name | capitalize"
[editable]="isEditable" >
<ng-template matStepLabel>
<mat-form-field class="sf-form-width">
<input class="sf-form-input"
matInput #title maxlength="30"
placeholder="Aprroval Step Title"
autocomplete="off">
<mat-hint *ngIf="title.value"
align="end">{{title.value.length}} / 30</mat-hint>
<button mat-button *ngIf="title.value"
matSuffix mat-icon-button aria-label="Clear"
(click)="title.value=''">
<mat-icon>close</mat-icon>
</button>
<button mat-button *ngIf="title.value"
matSuffix mat-icon-button aria-label="Set"
(click)="setTitle(group.sequence, title.value)">
<mat-icon>check</mat-icon>
</button>
</mat-form-field>
</ng-template>
...


below is a sample capture of what I have achieved.
enter image description here



Everything works fine until typing a words in mat-input does not accepts space input (spacebar keypress).



Any suggestions how to allow space key in mat-input inside mat-steps?





I have seen this in the documentations, is there a way to by pass SPACE event defaults?



Keyboard interaction




  • LEFT_ARROW: Focuses the previous step header

  • RIGHT_ARROW: Focuses the next step header


  • ENTER, SPACE: Selects the step that the focus is currently on

  • TAB: Focuses the next tabbable element

  • TAB+SHIFT: Focuses the previous tabbable element


https://material.angular.io/components/stepper/overview



https://stackblitz.com/edit/angular-9hm4bv







angular angular-material






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 31 '18 at 8:02









Cœur

18.1k9108148




18.1k9108148










asked Nov 20 '18 at 6:31









M.LaidaM.Laida

417110




417110













  • what happens currently when the space button is pressed?

    – JBoothUA
    Nov 20 '18 at 6:35











  • @JBoothUA - If I type a word "My Stepper", it display as "MyStepper", no space in between words.

    – M.Laida
    Nov 20 '18 at 6:39













  • I just tried on stackblitz its working fine!

    – Hrishikesh Kale
    Nov 20 '18 at 6:40











  • here is the link angular-wxpesf.stackblitz.io

    – Hrishikesh Kale
    Nov 20 '18 at 6:40






  • 1





    thanks, i think i have a working answer for you

    – JBoothUA
    Nov 21 '18 at 17:42



















  • what happens currently when the space button is pressed?

    – JBoothUA
    Nov 20 '18 at 6:35











  • @JBoothUA - If I type a word "My Stepper", it display as "MyStepper", no space in between words.

    – M.Laida
    Nov 20 '18 at 6:39













  • I just tried on stackblitz its working fine!

    – Hrishikesh Kale
    Nov 20 '18 at 6:40











  • here is the link angular-wxpesf.stackblitz.io

    – Hrishikesh Kale
    Nov 20 '18 at 6:40






  • 1





    thanks, i think i have a working answer for you

    – JBoothUA
    Nov 21 '18 at 17:42

















what happens currently when the space button is pressed?

– JBoothUA
Nov 20 '18 at 6:35





what happens currently when the space button is pressed?

– JBoothUA
Nov 20 '18 at 6:35













@JBoothUA - If I type a word "My Stepper", it display as "MyStepper", no space in between words.

– M.Laida
Nov 20 '18 at 6:39







@JBoothUA - If I type a word "My Stepper", it display as "MyStepper", no space in between words.

– M.Laida
Nov 20 '18 at 6:39















I just tried on stackblitz its working fine!

– Hrishikesh Kale
Nov 20 '18 at 6:40





I just tried on stackblitz its working fine!

– Hrishikesh Kale
Nov 20 '18 at 6:40













here is the link angular-wxpesf.stackblitz.io

– Hrishikesh Kale
Nov 20 '18 at 6:40





here is the link angular-wxpesf.stackblitz.io

– Hrishikesh Kale
Nov 20 '18 at 6:40




1




1





thanks, i think i have a working answer for you

– JBoothUA
Nov 21 '18 at 17:42





thanks, i think i have a working answer for you

– JBoothUA
Nov 21 '18 at 17:42












2 Answers
2






active

oldest

votes


















1














It appears that the issue is with the input field being within the ng-template.



See this example:



 <mat-step [stepControl]="firstFormGroup">
<form [formGroup]="firstFormGroup">
<ng-template matStepLabel>Fill out your name</ng-template>
<mat-form-field>
<input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
</mat-form-field>
<div>
<button mat-button matStepperNext>Next</button>
</div>
</form>
</mat-step>


It starts to work as expected if you remove the input and make it a sibling of the ng-template.






share|improve this answer



















  • 1





    thanks for your efforts and contribution.

    – M.Laida
    Nov 22 '18 at 1:59



















1














I seems that the mat-step header's keyboard interaction propagates to matInput, I have ended up using $event.stopPropagation() on keydown event of matInput.



Here is the stackblitz:



https://stackblitz.com/edit/angular-9hm4bv



sample image:
enter image description here



Hope It might be helpful to others.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387467%2fallow-space-key-in-mat-input-inside-mat-step%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    It appears that the issue is with the input field being within the ng-template.



    See this example:



     <mat-step [stepControl]="firstFormGroup">
    <form [formGroup]="firstFormGroup">
    <ng-template matStepLabel>Fill out your name</ng-template>
    <mat-form-field>
    <input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
    </mat-form-field>
    <div>
    <button mat-button matStepperNext>Next</button>
    </div>
    </form>
    </mat-step>


    It starts to work as expected if you remove the input and make it a sibling of the ng-template.






    share|improve this answer



















    • 1





      thanks for your efforts and contribution.

      – M.Laida
      Nov 22 '18 at 1:59
















    1














    It appears that the issue is with the input field being within the ng-template.



    See this example:



     <mat-step [stepControl]="firstFormGroup">
    <form [formGroup]="firstFormGroup">
    <ng-template matStepLabel>Fill out your name</ng-template>
    <mat-form-field>
    <input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
    </mat-form-field>
    <div>
    <button mat-button matStepperNext>Next</button>
    </div>
    </form>
    </mat-step>


    It starts to work as expected if you remove the input and make it a sibling of the ng-template.






    share|improve this answer



















    • 1





      thanks for your efforts and contribution.

      – M.Laida
      Nov 22 '18 at 1:59














    1












    1








    1







    It appears that the issue is with the input field being within the ng-template.



    See this example:



     <mat-step [stepControl]="firstFormGroup">
    <form [formGroup]="firstFormGroup">
    <ng-template matStepLabel>Fill out your name</ng-template>
    <mat-form-field>
    <input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
    </mat-form-field>
    <div>
    <button mat-button matStepperNext>Next</button>
    </div>
    </form>
    </mat-step>


    It starts to work as expected if you remove the input and make it a sibling of the ng-template.






    share|improve this answer













    It appears that the issue is with the input field being within the ng-template.



    See this example:



     <mat-step [stepControl]="firstFormGroup">
    <form [formGroup]="firstFormGroup">
    <ng-template matStepLabel>Fill out your name</ng-template>
    <mat-form-field>
    <input matInput placeholder="Last name, First name" formControlName="firstCtrl" required>
    </mat-form-field>
    <div>
    <button mat-button matStepperNext>Next</button>
    </div>
    </form>
    </mat-step>


    It starts to work as expected if you remove the input and make it a sibling of the ng-template.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 20 '18 at 10:46









    JBoothUAJBoothUA

    880425




    880425








    • 1





      thanks for your efforts and contribution.

      – M.Laida
      Nov 22 '18 at 1:59














    • 1





      thanks for your efforts and contribution.

      – M.Laida
      Nov 22 '18 at 1:59








    1




    1





    thanks for your efforts and contribution.

    – M.Laida
    Nov 22 '18 at 1:59





    thanks for your efforts and contribution.

    – M.Laida
    Nov 22 '18 at 1:59













    1














    I seems that the mat-step header's keyboard interaction propagates to matInput, I have ended up using $event.stopPropagation() on keydown event of matInput.



    Here is the stackblitz:



    https://stackblitz.com/edit/angular-9hm4bv



    sample image:
    enter image description here



    Hope It might be helpful to others.






    share|improve this answer




























      1














      I seems that the mat-step header's keyboard interaction propagates to matInput, I have ended up using $event.stopPropagation() on keydown event of matInput.



      Here is the stackblitz:



      https://stackblitz.com/edit/angular-9hm4bv



      sample image:
      enter image description here



      Hope It might be helpful to others.






      share|improve this answer


























        1












        1








        1







        I seems that the mat-step header's keyboard interaction propagates to matInput, I have ended up using $event.stopPropagation() on keydown event of matInput.



        Here is the stackblitz:



        https://stackblitz.com/edit/angular-9hm4bv



        sample image:
        enter image description here



        Hope It might be helpful to others.






        share|improve this answer













        I seems that the mat-step header's keyboard interaction propagates to matInput, I have ended up using $event.stopPropagation() on keydown event of matInput.



        Here is the stackblitz:



        https://stackblitz.com/edit/angular-9hm4bv



        sample image:
        enter image description here



        Hope It might be helpful to others.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 22 '18 at 2:08









        M.LaidaM.Laida

        417110




        417110






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53387467%2fallow-space-key-in-mat-input-inside-mat-step%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

            ComboBox Display Member on multiple fields

            Is it possible to collect Nectar points via Trainline?