vmware-archive / clarity

Clarity is a scalable, accessible, customizable, open source design system built with web components. Works with any JavaScript framework, built for enterprises, and designed to be inclusive.
http://clarity.design
MIT License
6.43k stars 763 forks source link

The internal clarity NgControlService should be exposed. #6647

Closed TodorBonchev closed 2 years ago

TodorBonchev commented 2 years ago

Describe the bug

We have a component with a clarity selector component and a clarity modal dialog. In the clarity modal dialog we show a clarity datagrid. When the modal is opened the NgControlService sets the control to some elements in the clarity datagrid and after the modal is closed the control is not returned to the clarity selector and the validations couldn't be triggered. In order to workaround this problem I have to write this code:

        const controlStateService: IfControlStateService = this.comboboxComponent['controlStateService'];
        if (!controlStateService) {
            console.error('controlStateService of clarity combobox is undefined.');
        } else {
            const ngControlService = controlStateService['ngControlService'];
            if (!ngControlService) {
                console.error('ngControlService of IfControlStateService is undefined');
            } else {
                ngControlService.setControl(this.controlBase);
            }
        }

to access the NgControlService and set the control to the selector component manually.

The clarity components should either expose the NgControlService as a public service or automatically detect which is the active control and make the validation working in all cases.

Versions

Clarity project:

Clarity version:

Framework:

Framework version:

: Angular 11_

The bug is not specific to a particular device.

Jinnie commented 2 years ago

Hi Todor, Please provide a StackBlitz reproduction so we can verify the usage case and see where the problem is. https://stackblitz.com/@clr-team/

github-actions[bot] commented 1 year ago

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.