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

Separate modal close from modal cancel event + allow programmatically toggling sam-toggle-switch #165

Open
kevin-song-reisys opened this issue Dec 3, 2018 · 3 comments

Comments

@kevin-song-reisys
Copy link
Contributor

kevin-song-reisys commented Dec 3, 2018

1-
Currently the modal component calls closeModal() when the cancel button is clicked (https://github.com/GSA/sam-ui-elements/blob/master/src/ui-kit/components/modal/modal.template.html#L21), and emits the corresponding event.

This works when opening the modal is not tied to a state change, however, if for example the modal opens upon turning on a toggle switch, if the user does not submit the modal then we need to rollback the toggle state to off.

Currently the close event emits both if the user cancels/closes or submits, so we cannot distinguish between the two cases within the onClose handler without adding additional tracking in the client component.

Can we separate these cases into three events?
close - always emits (already exists)
cancel - emits if modal is closed without submitting (new)
submit - emits if modal is submitted (already exists)

This will allow us to place any state cleanup code in the onCancel without needing to track the modal's internal state.

2-
Related to the above, there is currently no way no programmatically set the value of a sam-toggle-switch, but we may need to undo a toggle if it is conditional on additional steps like a modal. Can we add a method like setToggleValue?

@colinalford-gsa
Copy link
Contributor

@yerramshilpa @thomastighe Can you take a look at this?

@kevin-song-reisys This is a great topic for FWG as well.

@diego-ruiz
Copy link
Contributor

diego-ruiz commented Dec 3, 2018

@kevin-song-reisys @colinalford-gsa for the second item, because the component implements the control value accessor interface you should be able to set it via ngModel in template driven forms or the reactive way via setValue() or patchValue()

https://github.com/GSA/sam-ui-elements/blob/master/src/ui-kit/form-controls/toggle-switch/toggle-switch.component.ts#L30

@kevin-song-reisys
Copy link
Contributor Author

@diego-ruiz Good point, I forgot about that interface. I did try directly setting isSwitchOn value though, and I think it did update the value but did not trigger any events. Maybe we can add the same event emits/any other logic to the writeValue()?

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

No branches or pull requests

3 participants