Skip to content

Dynamically rendered Action(s) don't render in ActionPanel #1017

Closed

Description

@knownasilya

Raycast version: 1.29.1

Description

When rendering an <Action /> component dynamically, e.g. {isShown && <Action title="abc" />} does not show the Action, even if isShown is true.

Steps To Reproduce

  1. Conditionally render <Action /> in an <ActionPanel /> on a List.Item.
  2. Change the condition so that another action is rendered instead

The current behavior

Originally rendered action is always shown.

The expected behavior

The conditional should rerender the action that is expected to be there based on the logic.

Example Code

import { List, ActionPanel, Action } from '@raycast/api';
import { useEffect, useState } from 'react';

export default function Command() {
  const [isLoading, setIsLoading] = useState(true);
  const items = [{ name: 'Test' }];

  useEffect(() => {
    setIsLoading(true);

    setTimeout(() => setIsLoading(false), 100);
  }, []);

  return (
    <List navigationTitle="My Items">
      {items.map((item, index) => (
        <List.Item
          key={index}
          title={item.name}
          actions={
            <ActionPanel>
              {isLoading ? (
                <Action title="UnLoad" onAction={() => setIsLoading(false)} />
              ) : (
                <Action title="Load" onAction={() => setIsLoading(true)} />
              )}
            </ActionPanel>
          }
        />
      ))}
    </List>
  );
}

Activity

  1. added
    api
    bug
    on Mar 2, 2022
  2. sxn commented on Mar 2, 2022

    @sxn
    Collaborator

    hi @knownasilya, thanks for the report! This should be fixed in next release. 😉

  3. added
    status: fixed in next release
    on Mar 2, 2022
  4. self-assigned this
    on Mar 2, 2022
  5. knownasilya commented on Mar 9, 2022

    @knownasilya
    ContributorAuthor

    Nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

apibugstatus: fixed in next release

Type

No type

Fields

Priority

None yet

Severity

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions