Skip to content

Conversation

@Maksims
Copy link
Collaborator

@Maksims Maksims commented Aug 13, 2025

Fixes task in #1369

Select type fields can have a type of value like string or number, and then options to select from. While clipboard simply cares about type, this PR introduces a validation step, of ensuring that we can only paste a value if it is one of select options.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the clipboard functionality in the Inspector to validate enum/select type fields by ensuring pasted values are among the allowed options. The change adds validation for select fields that have predefined options, preventing invalid values from being pasted.

Key Changes

  • Added validation logic to check that clipboard values match available options for select/enum fields
  • Updated clipboard methods to accept and pass through field options parameter
  • Modified the attributes inspector to extract and provide select field options to clipboard operations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/editor/storage/clipboard-context-menu.ts Added options parameter to clipboard methods and implemented validation logic to check values against select field options
src/editor/inspector/attributes-inspector.ts Modified to extract field options from attribute args and pass them to clipboard operations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@kpal81xd kpal81xd left a comment

Choose a reason for hiding this comment

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

Nice!

@kpal81xd kpal81xd added enhancement enhancement New feature or request and removed enhancement labels Aug 13, 2025
@Maksims Maksims merged commit 41dc6c7 into playcanvas:main Aug 13, 2025
3 checks passed
@Maksims Maksims deleted the clipboard-enums branch August 13, 2025 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants