taiga-ui
taiga-ui copied to clipboard
🚀 - Provide some functionality to make controls readonly
Which @taiga-ui/* package(s) are relevant/releated to the feature request?
No response
Description
Please add some feature which will allow to make every control state readonly
@sFeels all controls have readOnly
input. Could you clarify your issue?
I mean something that can make every control readonly at once from the outside component template
we need readOnly = false;
change to readOnly = this.option.readOnly;
and users can
providers: [
tuiTextfieldControlOptions({ readOnly: true })
],
I'd like to implement this, but I need to clarify something. @splincode mentioned tuiTextfieldControlOptions
. The flow of the readOnly
input is: TuiAbstractControl
-> SomeComponent
-> TuiPrimitiveTextfield
, so using the additional TextfieldControlOptions
property won't work because the value of the provided option will be overridden by either TuiAbstractControl
or SomeComponent
.
To make it work with TuiTextfieldControlOptions
, it would have to be used in the constructor of the component like this
class TuiInputCardGroupedComponent {
constructor(
@Inject(TUI_TEXTFIELD_WATCHED_CONTROLLER)
readonly controller: TuiTextfieldController
) {
this.readOnly = this.controller.options.readOnly;
}
}
or create separate TuiControlOptions
and pass the controller.options
to AbstractTuiControl
in the constructor parameter.
However, if extending the AbstractTuiControl
constructor is an option, I think it's better to just add DI for AbstractTuiControl
. That way we'll provide the readOnly
provider for all controls, not just the ones with TuiTextfieldController
.
@waterplea, @splincode What do you think? Do you prefer any solution?
I think it's better to wait on this one before we update to Angular 14+ so we can use the inject
function. Otherwise it would make all constructors messy.