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

fix: undefined tags in field when editing #3315

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

coatezy
Copy link

@coatezy coatezy commented Oct 8, 2024

Description

This PR fixes an undefined tag issue when editing existing tags on a resource.

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works

Screenshots & recording

Before:

CleanShot 2024-10-08 at 13 12 48@2x
CleanShot 2024-10-08 at 13 00 44@2x

After:
CleanShot 2024-10-08 at 13 13 08@2x

Manual review steps

  1. Step 1
  2. Step 2

Manual reviewer: please leave a comment with output from the test if that's the case.

@github-actions github-actions bot added the Fix label Oct 8, 2024
Copy link

codeclimate bot commented Oct 8, 2024

Code Climate has analyzed commit 851affa and detected 0 issues on this pull request.

View more on Code Climate.

@coatezy coatezy changed the title Fix: Undefined tags in field when editing fix: undefined tags in field when editing Oct 8, 2024
@Paul-Bob
Copy link
Contributor

Paul-Bob commented Oct 9, 2024

Hey @coatezy thanks for the contribution! I noticed that some tests are failing. Could you please share the tags field code from your resource and more details about how to reproduce the issue?

@coatezy
Copy link
Author

coatezy commented Oct 9, 2024

Hey @coatezy thanks for the contribution! I noticed that some tests are failing. Could you please share the tags field code from your resource and more details about how to reproduce the issue?

Hey, @Paul-Bob! Not problem. I'd be happy to try and understand why these are failing. The tags field is configured in the following way on the resource.

    field :tags, as: :tags, acts_as_taggable_on: :tags

@Paul-Bob
Copy link
Contributor

Paul-Bob commented Oct 9, 2024

I was able to reproduce the issue, I guess the tests are failing because tags cover several use cases and this change fixes this particular use case but maybe is breaking another use case, I'll also have a look

@coatezy coatezy force-pushed the fix/undefined_tags_in_field_when_editing branch from 62be726 to 851affa Compare October 9, 2024 18:46
Copy link
Contributor

@Paul-Bob Paul-Bob left a comment

Choose a reason for hiding this comment

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

I suggested some changes that might be effective.

When using suggestions https://docs.avohq.io/3.0/fields/tags.html#possible-values as an array of hashes the possibleSuggestion will respond to label but when used as array of values or not used at all it will NOT respond to label

@@ -5,9 +5,9 @@ export function tagTemplate(tagData) {
// eslint-disable-next-line eqeqeq
(item) => item.value == tagData.value,
)
const possibleLabel = possibleSuggestion
const possibleLabel = possibleSuggestion.label
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const possibleLabel = possibleSuggestion.label
const possibleLabel = possibleSuggestion && 'label' in possibleSuggestion

? possibleSuggestion.label
: tagData.value
: tagData.value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
: tagData.value;
: tagData.value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants