-
Notifications
You must be signed in to change notification settings - Fork 166
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
fix(fuselage-ui-kit): Initial Value being ignored on text input fields upon modal update #600
Conversation
I think the behavior you mentioned might be intended, even if it's unclear. Because when you update a view, we assume that you're maintaining context (semantically speaking), only adjusting the presentation - so what is there should be kept; and when you open a new modal view (modals can be stacked up to 3 times IIRC) then you're changing the context completely, which allows for a totally new state. In the example you provided, for instance, ideally you should not be updating your view, but rather opening a new modal, since the context has completely changed. A possible side-effect of removing this behavior would be breaking the Poll app, since it relies on UIKit keeping the state of the form when you click the "Add a choice" button. See image: @sampaiodiego @ggazzo wdyt? |
Hi @d-gubert Firstly thanks for checking out this PR 😄
I totally agree with this point, if an input field has a value set by the user, then it should always maintain that value and the initialState prop shouldn't be allowed to change that. But this is not what's happening here... here there are 2 different inputs with 2 completely different Moreover, I wasn't able to replicate the poll app issue which you mentioned with the poll app. Could you please share some more details so I can reproduce this issue and check what's wrong here? poll-app-working-with-initial-state-fix.mp4On a side note: There's one more use-case I'd like to share here which is getting affected by this bug (this is a live one with a valid use-case). Try installing the poll-plus-app-live-question-issue-with-initialstate.mp4 |
Oh, I see! Yes, this makes sense.
Interesting, by the changes you've applied to the code I'd assume that would happen (I haven't tested it). But upon a closer look I think I see how it didn't. That's why we need a review from the Frontend team 😅 |
I need to check, has been a long time since I wrote this, but your solution doesn look good, if every single time I change |
thanks for bringing this issue to us
|
@ggazzo Thank you so much for looking into this issue and adding a proper fix. It indeed solves the issue 🚀 PS: While testing locally I found a minor issue with the Poll app message (specifically with the "Finish Poll" button) and added a fix for it. This was the error I was getting. It was just a minor null check issue 😉 |
Proposed changes (including videos or screenshots)
Issue(s)
When the app tries to update the modal with a new input field, the value from the previous input field still persists in the new input field - thus ignoring the
initialValue
param being passed from the app.Note this only occurs if the Input field is added via view-update (i.e via modify.getUiController().updateModalView()).
Please refer to the following demo for more info about this bug.
Also, the code for this sample app is available here. To test, simply install the app, and run
/multi-form create
command and replicate the issue as shown in the videomulti-form-issue.mp4
Further comments