Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear stepper without a form #8110

Closed
theunreal opened this issue Oct 29, 2017 · 6 comments · Fixed by #9126
Closed

Linear stepper without a form #8110

theunreal opened this issue Oct 29, 2017 · 6 comments · Fixed by #9126
Assignees
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@theunreal
Copy link

Bug, feature request, or proposal:

Proposal

What is the expected behavior?

Assign a condition for a step to be completed manually (form-independent)

What is the current behavior?

No option to mark step as completed without a form

What is the use-case or motivation for changing an existing behavior?

Fit more use cases

Is there anything else we should know?

for example:

<mat-horizontal-stepper formArrayName="formArray" linear [completed]="items.length">

@jelbourn jelbourn added feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Oct 29, 2017
@acvdb
Copy link

acvdb commented Nov 15, 2017

If a step doesn't contain a form, the following exception is thrown:

ERROR TypeError: Cannot read property 'invalid' of undefined
    at stepper.es5.js:375
    at Array.some (<anonymous>)
    at MatHorizontalStepper.webpackJsonp.../../../cdk/esm5/stepper.es5.js.CdkStepper._anyControlsInvalid (stepper.es5.js:375)
    at MatHorizontalStepper.set [as selectedIndex] (stepper.es5.js:206)
    at MatHorizontalStepper.webpackJsonp.../../../cdk/esm5/stepper.es5.js.CdkStepper.next (stepper.es5.js:240)
    at Object.eval [as handleEvent] (AppComponent.html:25)
    at handleEvent (core.es5.js:11998)
    at callWithDebugContext (core.es5.js:13467)
    at Object.debugHandleEvent [as handleEvent] (core.es5.js:13055)
    at dispatchEvent (core.es5.js:8614)

@crisbeto
Copy link
Member

crisbeto commented Dec 26, 2017

This should be possible already, can somebody confirm? It no longer throws an arrow when the stepControl is undefined and there's been a completed input on the step all along.

EDIT: Just double-checked. While the completed property is there, it's not being considered when the user tries to move to another step. I've submitted a PR to address it.

@crisbeto crisbeto self-assigned this Dec 26, 2017
crisbeto added a commit to crisbeto/material2 that referenced this issue Dec 26, 2017
… a step without a stepControl

Currently we only consider a step's validation state when determining whether the user can move forward in a linear stepper, however this means that there's no way to block navigation without using Angular forms. These changes switch the logic so it considers the `completed` binding, if there is `stepControl`.

Fixes angular#8110.
jelbourn pushed a commit that referenced this issue Jan 4, 2018
… a step without a stepControl (#9126)

Currently we only consider a step's validation state when determining whether the user can move forward in a linear stepper, however this means that there's no way to block navigation without using Angular forms. These changes switch the logic so it considers the `completed` binding, if there is `stepControl`.

Fixes #8110.
jelbourn pushed a commit to jelbourn/components that referenced this issue Jan 8, 2018
… a step without a stepControl (angular#9126)

Currently we only consider a step's validation state when determining whether the user can move forward in a linear stepper, however this means that there's no way to block navigation without using Angular forms. These changes switch the logic so it considers the `completed` binding, if there is `stepControl`.

Fixes angular#8110.
jelbourn pushed a commit to jelbourn/components that referenced this issue Jan 9, 2018
… a step without a stepControl (angular#9126)

Currently we only consider a step's validation state when determining whether the user can move forward in a linear stepper, however this means that there's no way to block navigation without using Angular forms. These changes switch the logic so it considers the `completed` binding, if there is `stepControl`.

Fixes angular#8110.
jelbourn pushed a commit that referenced this issue Jan 9, 2018
… a step without a stepControl (#9126)

Currently we only consider a step's validation state when determining whether the user can move forward in a linear stepper, however this means that there's no way to block navigation without using Angular forms. These changes switch the logic so it considers the `completed` binding, if there is `stepControl`.

Fixes #8110.
tinayuangao pushed a commit that referenced this issue Jan 10, 2018
… a step without a stepControl (#9126)

Currently we only consider a step's validation state when determining whether the user can move forward in a linear stepper, however this means that there's no way to block navigation without using Angular forms. These changes switch the logic so it considers the `completed` binding, if there is `stepControl`.

Fixes #8110.
@Dannythm
Copy link

Dannythm commented Jan 29, 2018

Sorry to comment on an already closed issue, but I think I get what @theunreal was aiming to, that is, to have a stepper that does not rely on form validators to be advanced.

Check this stackblitz: https://stackblitz.com/edit/mat-horizontal-stepper?file=app%2Fapp.component.html

I've marked the stepper as linear, and the first step as not optional, still, regardless of it, you can click and go to the step 2 at any time, without having to click the "compelte" button to mark step 1 as completed, also ot seen in there, when I try in my local environment to do the same I get the following error when clicking the complete button:

SearchComponent.html:62 ERROR TypeError: _co.compelte is not a function
    at Object.eval [as handleEvent] (SearchComponent.html:62)
    at handleEvent (core.js:13532)
    at callWithDebugContext (core.js:15041)
    at Object.debugHandleEvent [as handleEvent] (core.js:14628)
    at dispatchEvent (core.js:9944)
    at eval (core.js:10569)
    at HTMLButtonElement.eval (platform-browser.js:2628)
    at ZoneDelegate.invokeTask (zone.js:398)
    at Object.onInvokeTask (core.js:4724)
    at ZoneDelegate.invokeTask (zone.js:397)
    at Zone.runTask (zone.js:165)
    at HTMLButtonElement.ZoneTask.invoke (zone.js:460)

My use case is to have a stepper that on each step present the user certain options, and they have to select one of them with a button, then proceed to the following step, but not allow them to advance if there is no selection. If thsi is not possible I can think a redesign that uses forms but I really think I don't need to have forms for this use case, but I'm failing to achieve it so far.

Please correct me if I'm using any component the wrong way.

@Maistho
Copy link
Contributor

Maistho commented Jan 30, 2018

@Dannythm Looks like you need to bind to [completed]. See this modification of your stackblitz:

https://stackblitz.com/edit/mat-horizontal-stepper-5d2ttr

@Dannythm
Copy link

@Maistho Ah, so the properties can't be used directly, they need binding, oh well I feel dumb now. Anyway I'm glad it's something silly and not an actual non functionallity/bug. Thank you!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
6 participants