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 multi-select-menu initial-options #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "phelia",
"version": "0.1.11",
"name": "@spotim/phelia",
"version": "0.1.12-fix-initial-options",
"main": "dist/index.js",
"license": "MIT",
"repository": "https://github.com/maxchehab/phelia",
Expand Down
15 changes: 9 additions & 6 deletions src/core/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -535,11 +535,11 @@ interface BaseModalProps {

/**
* An optional callback that executes when the modal is submitted.
*/
*/
onSubmit?: (event: SubmitEvent) => Promise<void>;
/**
* An optional callback that executes when the modal is canceled.
*/
*/
onCancel?: (event: InteractionEvent) => Promise<void>;
}

Expand All @@ -554,7 +554,7 @@ type RootModalProps = BaseModalProps & {
* An optional callback that executes when the modal is canceled.
*/
onCancel?: (event: InteractionEvent) => Promise<void>;
}
};

type InlineModalProps = BaseModalProps & {
/** A modal subtype indicating this modal was opened by another component. */
Expand Down Expand Up @@ -1223,8 +1223,8 @@ interface MultiUserSelectMenu extends MultiSelectMenuBase {
interface MultiChannelSelectMenu extends MultiSelectMenuBase {
/** The type of the multi select. */
type: "channels";
/**
* An array of one or more IDs of any valid public channel to be pre-selected
/**
* An array of one or more IDs of any valid public channel to be pre-selected
* when the menu loads.
v*/
initialChannels?: string[];
Expand Down Expand Up @@ -1305,9 +1305,12 @@ export const MultiSelectMenu = (props: MultiSelectMenuProps) => (
const [{ fields: optionsOrGroups }, optionPromises] = reconcile(
React.createElement(Section, { children: props.children })
);
const [{ fields: initialOptions }, initialOptionsPromises] = reconcile(
const [, initialOptionsPromises] = reconcile(
Copy link
Author

@dutzi dutzi Dec 28, 2020

Choose a reason for hiding this comment

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

For some reason, I had to keep calling reconcile on React.createElement(Section, ..., otherwise initial options wouldn't render

React.createElement(Section, { children: props.children })
);
const initialOptions = props.initialOptions?.map(
(option: any) => reconcile(option)[0]
);

if (
props.type === "static" &&
Expand Down