Skip to content

Conversation

@Monkeychip
Copy link
Contributor

@Monkeychip Monkeychip commented Feb 19, 2025

  • ent test pass

Description

What was originally intended as a simple CSS cleanup revealed an issue with how we were using model attributes editType: searchSelect with type: string. These two attributes were incompatible during an edit scenario. There is one other case where these two attributes are used together, but in that case, the editDisabled: true flag prevented any issues from surfacing during editing.

In the model/transform.js the template attribute was incorrectly labeled as type="array". According to the API here, template should be type "string". Updating the model type fixed the styling issue, but it broke the edit functionality.

To resolve the edit issue, I modified the method responsible for reading the attribute’s value in the searchSelect component. If the value wasn't already an array, I converted it into an array so the function could process it correctly. This approach seemed to be the least disruptive solution.

Before:
image

After:
image

@Monkeychip Monkeychip added this to the 1.19.1 milestone Feb 19, 2025
@Monkeychip Monkeychip requested a review from a team as a code owner February 19, 2025 18:01
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Feb 19, 2025
@github-actions
Copy link

github-actions bot commented Feb 19, 2025

CI Results: failed ❌

@github-actions
Copy link

github-actions bot commented Feb 19, 2025

Build Results:
All builds succeeded! ✅

})
masking_character;

// TODO: add presence required validation for template
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the only real change on the model, everything else is due to glimmerizing

Comment on lines 113 to 116
// For model attributes using editType: 'searchSelect' where the API returns a string,
// we need to wrap the value in an array to match the format expected by the dropdownOptions.
// Example: model/transform.js -> template
inputValues = Array.isArray(inputValues) ? inputValues : [inputValues];
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add a test for this behavior? Search select is a pretty bloated component as is, so I'm nervous to add even seemingly small logic to it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test coverage is incoming. It's a mess in there, so I stayed with selector patterns that existed and added coverage for search select but also acceptance test coverage for the create/edit workflow.

Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

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

A few thoughts here, if you want to go this route. I definitely think we need a test.

Alternatively, it seems like the edit type in the model was "array" may have been to leverage built-in ember data transform magic ✨ . Or there's also a templates attribute returned by the API (docs), maybe the model was supposed to reference that parameter and should be plural

Also, I'm not seeing an issue locally - what's the original bug that's being fixed here? The transform template seems to edit just fine 🤔

assert.dom('.list-item-text').exists('selected option field has width set');
assert.dom('.text-overflow-ellipsis').exists('selected option text has overflow class');
});

Copy link
Contributor Author

Choose a reason for hiding this comment

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

inputValue is the only argument passed into the formatInputAndUpdateDropdown method that was modified in this PR. In this test, we're testing when inputValue is a string. InputValue as an array is tested in the test above this here

@Monkeychip Monkeychip modified the milestones: 1.19.1, 1.20.0-rc Feb 19, 2025
@Monkeychip
Copy link
Contributor Author

Not a priority, more of a rabbit hole, type situation will be resolved in later ember data work.

@Monkeychip Monkeychip closed this Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed pr/no-changelog ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants