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

feat(cdk-stepper): change orientation on runtime or expose key manager property #21874

Closed
Phil147 opened this issue Feb 11, 2021 · 2 comments · Fixed by #21940, cayacdev/cashbox#88, ToWipf/jasmarty#155 or CarlosPavajeau/Kaizen#251
Assignees
Labels
area: cdk/stepper 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

@Phil147
Copy link

Phil147 commented Feb 11, 2021

Feature Description

Make it possible to change the orientation between horizontal and vertical during runtime. This could also be made possible by exposing the current private _keyManager property either by making it protected or providing a public getter/method so that the consumer of the CdkStepper can manage that on their own.

Use Case

In our case we want to be able to switch between vertical and horizontal orientation on a single component via an Input. Switching orientation should have some effects, most importantly that keyboard controls should be different (UP and DOWN arrows for vertical orientation).
In the current implementation and how it is implemented in material that is done by two separate components that explicitly set the _orientation property and setting the keymanager up in the ngAfterViewInit hook.

Pseudo Code what we'd like to do:

export class MyStepper extends CdkStepper {
  @Input()
  set direction(value) {
    this._direction = value;
    this._keyManager.withVerticalOrientation(this._direction === 'vertical');
  }
}

Right now I think just changing the orientation in the keyManager should be enough, even nicer would be that the CdkStepper would already support setting the _orientation property dynamically, but I'd understand if you don't want to support that inside the CdkStepper. In this case exposing the keyManager would give us as the consumer the possibility at our own risk to implement this feature and not being forced into doing two separate components.

What do you think? I am happy to open a PR if you want to support that use case.

@Phil147 Phil147 added feature This issue represents a new feature or feature request rather than a bug or bug fix needs triage This issue needs to be triaged by the team labels Feb 11, 2021
@crisbeto crisbeto added area: cdk/stepper P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent and removed needs triage This issue needs to be triaged by the team labels Feb 15, 2021
@crisbeto crisbeto self-assigned this Feb 18, 2021
crisbeto added a commit to crisbeto/material2 that referenced this issue Feb 18, 2021
Currently we have a limitation on the Material stepper that doesn't allow its orientation
to be changed dynamically, because we have two different components for it.

The CDK stepper doesn't have this limitation and people may end up extending it to
implement their own steppers which support changing orientations.

These changes add some logic to ensure that changing the orientation works as expected
and to ensure that the orientation of the Material stepper doesn't change.

Fixes angular#21874.
@crisbeto
Copy link
Member

crisbeto commented Feb 18, 2021

I've submitted #21940 which adds a getter/setter to the CdkStepper. It's worth noting that the orientation field isn't an Input so that it doesn't bleed into MatStepper which doesn't support changing the orientation. You can do the following to turn it into an input for your custom stepper:

@Component({
  selector: 'my-stepper',
  inputs: ['orientation']
})
class MyStepper extends CdkStepper {}

andrewseguin pushed a commit that referenced this issue Feb 23, 2021
Currently we have a limitation on the Material stepper that doesn't allow its orientation
to be changed dynamically, because we have two different components for it.

The CDK stepper doesn't have this limitation and people may end up extending it to
implement their own steppers which support changing orientations.

These changes add some logic to ensure that changing the orientation works as expected
and to ensure that the orientation of the Material stepper doesn't change.

Fixes #21874.
@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 Mar 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.