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

Callback on perform, without replacing perform #355

Open
osszoi opened this issue Mar 1, 2024 · 1 comment
Open

Callback on perform, without replacing perform #355

osszoi opened this issue Mar 1, 2024 · 1 comment
Labels
wontfix This will not be worked on

Comments

@osszoi
Copy link

osszoi commented Mar 1, 2024

Hi, I'm trying to implement kbar as a search through the app bar. The thing is I have many sections and I'd like to load items from section only when needed, I have this code that loads at start all Programs:

export const useCommandActions = () => {
  const navigate = useNavigate();

  const programs = createAction({
    name: 'Programas',
    // shortcut: ['p'],
    icon: <School />,
    section: 'Secciones'
  });

  const [actions, setActions] = useState([
    programs,
    createAction({
      name: 'Lista de programas',
      icon: <List />,
      section: 'Navegación',
      // shortcut: ['l'],
      parent: programs.id,
      perform: () => navigate(PATHS.ProgramsList)
    })
  ]);

  useEffect(() => {
    API.Program.getList({ page: 0, size: 9999 }).then((response) => {
      setActions((prev) => [
        ...prev,
        ...response.content.map(({ id, name, description, byCalendar }) =>
          createAction({
            name,
            subtitle: description,
            icon: !!byCalendar && <CalendarMonth />,
            keywords: `${name} ${id}`,
            section: 'Programas',
            perform: () => {
              navigate(PATHS.ProgramView.replace(':programId', id));
            },
            parent: programs.id
          })
        )
      ]);
    });
  }, []);

  useRegisterActions(actions, [actions]);
};

I'd like to load them ONLY when programs action is opened, but if I add perform to it I can load them but then I don't know how to go to the childs as it automatically do when I don't pass perform

Copy link

stale bot commented Jun 29, 2024

Hey! This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

1 participant