When <datalist></datalist> is used without defining a <clr-datalist-container> it throws the following error:
ERROR NullInjectorError: StaticInjectorError(AppModule)[ClrDatalist -> DatalistIdService]:
StaticInjectorError(Platform: core)[ClrDatalist -> DatalistIdService]:
NullInjectorError: No provider for DatalistIdService!
Steps to reproduce the behavior:
DatalistIdService should not be called when a <datalist> tag is defined without the <clr-datalist-container>
App
Device:
_Add any other notes about the problem here._
DatalistIdService is provided by the clr-datalist-container. Your working example in the stackblitz is the correct way to use this component.
Closing as this is an implementation question and not an issue.
DatalistIdService is provided by the clr-datalist-container.
That is true, but when we wish to use datalist input as a native html element or in another type of component (not as a clarity-datalist and therefore, without the clr-datalist-container) it breaks the application since it looks for a DatalistIdService . In the stackblitz the native input with datalist is shown, not the clarity one since the error is occured on the native datalist.
As reference: if a native html select is used, without the clarity directive on the input and without the clr-select-container it does not break the application. The native select and clarity-select can be used interchangeably .
We should guard against this a little better, at least throw an exception to explain it (as we do with passwords) or handle it gracefully.
I think that overriding the HTML5-default 'datalist' selector is causing this: https://github.com/vmware/clarity/blob/d087d40e623bd472e397e5374e6e4ecf02507b11/src/clr-angular/forms/datalist/datalist.ts#L13 .
Is it possible to check if the 'datalist' selector is used inside of the <clr-datalist-container>?
The selector should stay, but we need to basically make the directive inert unless its inside the container (which we can detect). Should be a small fix.
I'll fix it this week and submit a PR with @ Optional on the service and then add a check for the service before setting the id. Should be pretty simple. (I know, I know, those are famous last words but this is not the datagrid :) )
Hi there 馃憢, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.
Most helpful comment
I'll fix it this week and submit a PR with
@ Optionalon the service and then add a check for the service before setting the id. Should be pretty simple. (I know, I know, those are famous last words but this is not the datagrid :) )