Skip to content

Fields with custom components ignore admin condition #453

Closed

Description

@oranoran

Bug Report

A field with a custom component ignores the provided condition function, and always renders.

Expected Behavior

If the condition function evaluates to false, it should not render.

Steps to Reproduce

See the reproduction repo.

This has 2 fields with the same condition - a regular text field, and a text field with a custom component.
The field with the custom component always renders, regardless of the condition outcome.

Detailed Description

Payload 14.0 and 0.14.24-beta.0

Activity

  1. jmikrut commented on Feb 15, 2022

    @jmikrut
    Member

    Hey @oranoran — this should actually be documented but it is actually functioning as intended, however the intended functionality could be up for debate.

    Right now, we export withCondition as a HOC from payload/components/forms. You can wrap your custom component with this HOC and then boom - conditions work.

    The question is - should this be done for you? The reason that we did not auto-wrap custom components in withCondition is because sometimes you might want to control conditions yourself as part of the custom component - for example, this discussion.

    I'll move this over to a discussion but I'd like to keep the convo going!

  2. locked and limited conversation to collaborators on Feb 15, 2022
  3. converted this issue into a discussion #454 on Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions