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

Reactive form disable support #223

Open
dmoojunk opened this issue Nov 18, 2020 · 7 comments · May be fixed by #390
Open

Reactive form disable support #223

dmoojunk opened this issue Nov 18, 2020 · 7 comments · May be fixed by #390

Comments

@dmoojunk
Copy link

Currently Im having fun trying to integrate this into a reactive form that uses form groups - and toggles them on and off with enable() and disable(). This just recursively calls the same on the child controls.

Interestingly, the styling does change, however they are still editable if you click. Here is a small demo -
https://stackblitz.com/edit/angular-ivy-cstipf?file=src/app/hello.component.ts

Wondered if this could be supported, or perhaps a workaround suggestion?

Thanks for your library and time!

@mariocalin
Copy link

Anything on this issue? I am having the same problem. I disable the control but it keeps being editable in the form.

hakla pushed a commit to hakla/ngx-slider that referenced this issue Oct 12, 2021
@hakla
Copy link

hakla commented Oct 13, 2021

I fixed this issue and will make a pull request for it next week (I'd like to add some e2e tests for it first).

@SarcevicAntonio
Copy link

SarcevicAntonio commented Nov 16, 2021

We could really use a fix about now.

@hakla is there a workaround we can use as consumers?

One half-workaround is to conditionally add a class that adds pointer-events: none; but this only disables mouse input changes, not keyboard input.

@eulersson
Copy link
Contributor

eulersson commented Nov 19, 2021

Same issue, I was trying to dynamically change the options dictionary that gets set into the slider. There's an option disabled. But changing it hotly doesn't update the component.

The workaround I am using is to use @ViewChild and select the component. Then calling setDisabledState(trueOrFalse).

A TypeScript problem is that the module does not export the SliderComponent, it only exports the NgxSliderModule, so I cannot tell it is going to be a SliderComponent, instead I have to turn off TypeScript resolution and use the infamous any:

@Component({
  selector: 'mycomp',
  template: `<button (click)="disableSlider()">Disable Slider</button><ngx-slider #mySlider ...></ngx-slider>`
  ...
})
export class MyCompComponent {
    @ViewChild('mySlider') sliderComponent!: any;

    disableSlider() {
      this.sliderComponent?.setDisabledState(true);
    }
    
}

I created two issues and I am happy to work on them if I get an OK from the mantainers of this project:

@SarcevicAntonio
Copy link

This works, but only makes it styled like it's disabled. You can still click and drag the slider 👀

@eulersson
Copy link
Contributor

This works, but only makes it styled like it's disabled. You can still click and drag the slider 👀

That is true 😢

@hakla
Copy link

hakla commented Nov 25, 2021

@SarcevicAntonio Sorry for the late reply, I did not find the time to create the e2e tests as I wanted. For our project, I created an npm package that we are using until this is merged into ngx-slider. You can use this as well and switch back to the official slider after it is merged. It is available under the name @hakla/ngx-slider.

hakla pushed a commit to hakla/ngx-slider that referenced this issue Nov 27, 2024
hakla pushed a commit to hakla/ngx-slider that referenced this issue Nov 28, 2024
@hakla hakla linked a pull request Nov 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants