#Button is unresponsive after 1st click...what is going on?
1 messages · Page 1 of 1 (latest)
It's probably because you're not giving a lot of information. Remember, we can't see your code and what's happening on your screen. If you want anyone to help you, please provide a minimal reproduction of what you're doing.
hmm...
if the feature flag is on, then open the unlink shared rule modal
if not, then open a different modal
on the modal, there is a save button
and that is a general save button
the first save click works! but then any subsequent save click results in no action
what is going on?
Have you tried adding some console.log's to see which condition is reached on the second click? What happens when you close the modal, are you assigning false to the opened modal property?
is angular not great at state management?
the console.log("here") prints everytime I click on the save button
Not sure what you expect Angular to do here? If that condition is reached, but the modal isn't opened you need to look at the logic responsible for opening it. this.unlinkSharedRuleModal = true; Is this set to false anywhere when the modal is closed?
i have a method called cancelUnlinkSharedRuleModal() where it does this:
public cancelUnlinkSharedRuleModal(): void {
this.unlinkSharedRuleModal = false;
}
and how is this method called? Have you checked that closing the modal calls this method? For a modal I would normally expect modal.open() or modal.close() methods, not just setting a class property to true or false. Is it just working with a *ngIf?
so in the template, the modal is called like:
<ui-modal [isOpen]="unlinkSharedRuleModal" ...
no *ngIf
Ok, do you have access to this modal or is 3rd party? Still not sure how the method to set the property to false is called.
and how is this method called? Have you checked that closing the modal calls this method?
as you can see when the user clicks on the Cancel button, it calls the cancelUnlinkSharedRuleModal() method
And have you confirmed that the property is correctly set to false?
when user clicks on cancel, yes, unlinkSharedRuleModal is set to false
Ok, and the modal is 3rd party or do you have access to it>
ui-modal is built by a previous team
not a 3rd party
it uses EventEmitter from angular/core
ok, and what about this (onDismiss)="null"? This looks like the event the modal emits when it's closed, correct?
correct!
so, why isn't that calling cancelUnlinkSharedRuleModal()?
cancelUnlinkSharedRuleModal() is called at the click action
It looks like the modal is holding internal state and you're trying to go around the logic to close the modal
internal state? what do you mean?
doesn't the modal provide a way to close it? Instead of you having to create a method for it?
you're teling the modal to open by using one of it's inputs isOpen, but you also need to tell the modal when it's closed so it can reset it's internal state
the cancelUnlinkSharedRuleModal() method is for when user clicks on the Cancel link
i don't know how to activate a cancel without a method
Ok, what happens when you click on the X? I guess the modal will close, but there's no call to cancelUnlinkSharedRuleModal()
yup, when X is clicked on, it closes the modal
not sure how i can get the cancel link to behave like the X'
Hard for me to say since i'm not familiar with how the modal logic is implemented
if you click x, you're able to open it again?
yup!
there is no disruption
the modal logic for the X is:
@Output() public onDismiss = new EventEmitter<void>();
well, the click event is probably somewhere in the template for the modal. Can you check which method that is calling?
probably in the onDismiss:
<ui-modal [isOpen]="unlinkSharedRuleModal" [allowCancel]="true" (onDismiss)="null">
That's in your component template, but I assume the html for the X (including click event) is in the template for the modal component
gotcha
okay, i'm doing more fiddling around
and the second click seems to be unresponsible when i click X on the modal
So, the modal was created by another team. Is there no documentation for it or can you maybe see how it's used in other projects?
found the problem
(onDismiss)="null"
there is no state saved
i have to set a false state instead of setting it to null
Good to hear you found the problem 🙂