Separate modal close from modal cancel event + allow programmatically toggling sam-toggle-switch
- Dominant language
- TypeScript
- Stars
- 8
- Forks
- 33
- Avg merge
- 2d 51m
- Merged PRs (30d)
- 65
Description
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`?
Contributor guide
Assessment
This issue has not been assessed yet.