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

Fix interactive dialogs not showing #8427

Merged
merged 2 commits into from
Dec 18, 2024
Merged

Fix interactive dialogs not showing #8427

merged 2 commits into from
Dec 18, 2024

Conversation

larkox
Copy link
Contributor

@larkox larkox commented Dec 18, 2024

Summary

We were forcing having a value for the dialog elements. This PR removes that limitation, and fixes the types around it.

Ticket Link

Fix: https://mattermost.atlassian.net/browse/MM-62299

Release Note

Fix issue with interactive dialog not showing all the elements

@larkox larkox added 2: Dev Review Requires review by a core commiter 3: QA Review Requires review by a QA tester labels Dec 18, 2024
@larkox larkox requested review from a team and hmhealey and removed request for a team December 18, 2024 16:41
@jwilander jwilander requested review from cpoile, rahimrahman and DHaussermann and removed request for hmhealey December 18, 2024 17:07
Copy link
Member

@cpoile cpoile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking comments/questions. Thanks @larkox!

@@ -55,7 +55,7 @@ type Props = {
maxLength?: number;
optional: boolean;
onChange: (value: string) => void;
value: string;
value: string | undefined;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: any reason why it's not

Suggested change
value: string | undefined;
value?: string;

to match the ones above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First one I did, I forgot to update 😅

@@ -59,7 +74,7 @@ function DialogElement({
return;
}
onChange(name, newValue);
}, [onChange, type, subtype]);
}, [type, subtype, onChange, name]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the parseInt above, does newValue as string work if newValue is a string[]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that string[] is only getting into this function if we were to accept multiselect selectors (we accept that for Apps but not for Interactive Dialogs). But then the type and subtype won't be text and number.

Copy link
Contributor

@rahimrahman rahimrahman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only have questions.

I would have loved to see a test to cover the changes, specifically the "fix" that would cause the dialog element to appear because the value is no longer blank?

app/screens/interactive_dialog/dialog_element.tsx Outdated Show resolved Hide resolved
@@ -22,6 +22,21 @@ function selectKeyboardType(type: InteractiveDialogElementType, subtype?: Intera
return selectKB(subtype);
}

function getStringValue(value: string | number | boolean | string[] | undefined): string | undefined {
Copy link
Contributor

@rahimrahman rahimrahman Dec 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any value (heh, pun intended) in converting false to string and gets "false"?

I was thinking of option "true" / "false", but I have a feeling this gets converted somewhere already.

    if (typeof value === 'number' || typeof value === 'boolean') {
        return value.toString();
    }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe if I understand correctly, the initValues function would have converted that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
function getStringValue(value: string | number | boolean | string[] | undefined): string | undefined {
function getStringValue(value?: string | number | boolean | string[]): string | undefined {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True/false values should only be used on Boolean settings, and those will use the getBooleanValue. If a boolean value gets into this point, probably is because something is "wrong", and undefined is the safe approach.

But I don't have a strong opinion on this. Nevertheless, it "should never happen".

Regarding the change to getStringValue, I would argue the argument is not optional. You must provide an argument, just that that argument can be undefined. 0/5 on that too, so if you have a strong opinion, happy to change it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking of consistency. Since if people can pass undefined, it's almost like not
passing anything. But it is silly to see getStringValue(). I rather see people send getStringValue(undefined) instead of getStringValue().

Long to short: don't change. :P

@jwilander jwilander added this to the v2.23.0 milestone Dec 18, 2024
@larkox
Copy link
Contributor Author

larkox commented Dec 18, 2024

@DHaussermann DHaussermann added Build App for iOS Build the mobile app for iOS Build Apps for PR Build the mobile app for iOS and Android to test and removed Build App for iOS Build the mobile app for iOS labels Dec 18, 2024
Copy link

@DHaussermann DHaussermann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Confirmed Demo Plugin contains dialogue with several fields and field type some of witch were affected by the issue
  • Confirmed all fields are now showing including those affected by this issue
  • All dialogues I tested can be open and submitted (or canceled)
  • As a precaution, I used an ngrok tunnel to see the payload in the submission all fields including those affected are submitting data accurately
  • Regression testes using fields and dialogues of various types
  • Testing done on both Android and iOS
    No issues found

LGTM!

@DHaussermann DHaussermann added QA Review Done and removed Build Apps for PR Build the mobile app for iOS and Android to test 3: QA Review Requires review by a QA tester labels Dec 18, 2024
@jwilander jwilander added 4: Reviews Complete All reviewers have approved the pull request and removed 2: Dev Review Requires review by a core commiter labels Dec 18, 2024
@jwilander jwilander merged commit d75cbcd into main Dec 18, 2024
30 checks passed
@jwilander jwilander deleted the fixDialogs branch December 18, 2024 20:54
@jwilander jwilander added the CherryPick/Approved Meant for the quality or patch release tracked in the milestone label Dec 18, 2024
@jwilander
Copy link
Member

/cherry-pick release-2.23

@mattermost-build
Copy link
Contributor

Cherry pick is scheduled.

mattermost-build pushed a commit that referenced this pull request Dec 18, 2024
* Fix interactive dialogs not showing

* Use conditionals

(cherry picked from commit d75cbcd)
@mattermost-build mattermost-build added CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone and removed CherryPick/Approved Meant for the quality or patch release tracked in the milestone labels Dec 18, 2024
@jwilander
Copy link
Member

/cherry-pick release-2.24

@mattermost-build
Copy link
Contributor

Cherry pick is scheduled.

mattermost-build pushed a commit that referenced this pull request Dec 18, 2024
* Fix interactive dialogs not showing

* Use conditionals

(cherry picked from commit d75cbcd)
jwilander pushed a commit that referenced this pull request Dec 18, 2024
* Fix interactive dialogs not showing

* Use conditionals

(cherry picked from commit d75cbcd)

Co-authored-by: Daniel Espino García <[email protected]>
jwilander pushed a commit that referenced this pull request Dec 18, 2024
* Fix interactive dialogs not showing

* Use conditionals

(cherry picked from commit d75cbcd)

Co-authored-by: Daniel Espino García <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4: Reviews Complete All reviewers have approved the pull request CherryPick/Done Successfully cherry-picked to the quality or patch release tracked in the milestone QA Review Done release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants