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

Possible to Dynamically Load Command Palette Content? #20

Open
Calhistorian opened this issue Jun 16, 2023 · 3 comments
Open

Possible to Dynamically Load Command Palette Content? #20

Calhistorian opened this issue Jun 16, 2023 · 3 comments

Comments

@Calhistorian
Copy link

Calhistorian commented Jun 16, 2023

Just curious if there is an option to dynamically add actions to the command palette. I was able to modify the <Root> actions parameter to accept a Solid signal and then dynamically add actions using a generic timeout. But I couldn't seem add actions more than once.

I am very new to SolidJS - and never learned much of React. I would be interested in some kind of collaboration on this front as this will end up in a production environment.

(Edited for clarity)

@Calhistorian Calhistorian changed the title Possible to Dynamically Load Command Palette Content Possible to Dynamically Load Command Palette Content? Jun 16, 2023
@itaditya
Copy link
Owner

itaditya commented Jun 20, 2023

The way it's designed you need to register all the actions upfront but you can choose to enable actions conditionally so they don't show up at the start.

Also an action can receive dynamic data from the active component tree. Example- https://github.com/itaditya/solid-command-palette/blob/main/src/app/views/demo/DynamicActionContextDemo/DynamicActionContextDemo.tsx#L39

@Calhistorian
Copy link
Author

Calhistorian commented Jun 20, 2023

Thank you for the example. I will check it out.

Basically I am looking to offer some routing capability to quickly jump to portions of the application based on a GUID - but the set of possible routes is dynamic through the life-cycle of the application requiring at minimum for the command palette to know the GUID and title.

Do you think this would be possible? ( I will take a look at the code in the meantime )

My current implementation:
I have a parent component that is basically like "Open". Then a list of possible destinations appear as child items to choose to navigate to. But the list of options must be dynamic as the application state changes constantly.

(Edit: Added example)

@itaditya
Copy link
Owner

Got it, currently it's only possible if at the start of app you can create a list of routes but then disable the disallowed ones conditionally

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants