Conversation
|
@jlamanskygitt It looks like you created a new field type for this component. It should actually be used for the existing |
409bff8 to
6303cfd
Compare
| <div class="input-group"> | ||
| <input | ||
| type="text" | ||
| class="link-input input-group-field" |
There was a problem hiding this comment.
Please do a search in the project for link-input to find all of the javascript that is run based on that class. We need to test that we can remove that outdated js code without affected functionality.
Code ReviewThanks for this refactor! Moving the Bug: Deleted options not filteredThe original code explicitly skipped options marked as deleted: if ( isset( $option_value['deleted'] ) && $option_value['deleted'] === true ) {
continue;
}The new $filtered_options = array_filter($default_options, function ($value) {
return \!(isset($value['deleted']) && $value['deleted'] === true);
});
$options_array = array_map(function ($key, $value) {
return [
'id' => (string) $key,
'label' => $value['label'] ?? $key,
];
}, array_keys($filtered_options), $filtered_options);Missing icon data in optionsThe original dropdown rendered per-option icons via 'icon' => $value['icon'] ?? null,Minor:
|
| Architecture | ✅ Correct approach — moves link rendering into DT_Components alongside other field types |
| Deleted options filter | ❌ Missing — will expose deleted link types to users |
| Icon support | |
| Code consistency | ✅ Matches existing patterns in the class |
The deleted-options bug should be fixed before merge. The icon question depends on whether dt-multi-text-groups supports per-group icons, but worth verifying.
|
Functionally, this looks great. Really nice work! Just waiting on the cleanup of the old code. |
Code ReviewThanks for working on migrating the Critical: Missing web componentThe new This means link fields will not render at all after this PR is merged. Is this component being developed in a separate PR against Bug: Deleted link options not filteredThe original code explicitly skipped options marked as deleted: if ( isset( $option_value['deleted'] ) && $option_value['deleted'] === true ) {
continue;
}The new $options_array = array_map(function ( $key, $value ) {
return [
'id' => (string) $key,
'label' => $value['label'] ?? $key
];
}, array_keys( $default_options ), $default_options);Deleted link types will appear as options in the UI unless Bug: Missing null check on
|
| Severity | Issue |
|---|---|
| Critical | dt-multi-text-groups web component does not exist in the codebase |
| Bug | Deleted options not filtered from groups array |
| Bug | Missing ?? [] null check on default key |
| Cleanup | Orphaned JS: addLink, add-link-dropdown handlers, is_link_field_value_already_in_primary |
| Cleanup | Orphaned SCSS for link field styles |
| Minor | icon not forwarded in options array |
The architectural direction is good and consistent with the existing component pattern. Once the dt-multi-text-groups component exists and the above issues are resolved, this will be a clean migration.
Otherwise it seems to be looking good. There are branch conflicts, so make sure you merge the develop branch back into this branch again to get it up-to-date. |
Code Review
High
When a record is created successfully but a file upload fails:
Clicking submit again creates a second record with the same data. The first record exists (without the file) and is now an orphan the user does not know about. The fix is to redirect to the created record even when uploads fail, and surface the upload error on the detail page instead of leaving the user on the new-record form. Medium
The strings
When SummaryThe file-upload-failure / duplicate-record bug in |
Code Review
Medium
In the new if (valIdx < 0 || mergeContact) {
mergedValue.push(sourceItem);
if (mergeContact) {
sourceItem.meta_id = "";
}
}The Concretely: if the select event fires more than once for the same checkbox (e.g., rapid clicks, programmatic re-triggers, or a page state issue), the same link entry will be duplicated in The fix is to drop the if (valIdx < 0) {
if (mergeContact) {
sourceItem.meta_id = "";
}
mergedValue.push(sourceItem);
}
In the new deselect path: } else {
if (!is_field_value_still_selected(update_field_id, field_type, sourceItem)) {
if (mergeContact) {
mergedValue.splice(valIdx, 1); // valIdx can be -1
}
}
}If Note: the if (mergeContact && valIdx > -1) {
mergedValue.splice(valIdx, 1);
}SummaryThe architecture is correct and consistent with other web component migrations. The two issues above are in the new merge-contact selection logic and can cause data corruption (duplicated or dropped link values) during the merge workflow. Both are straightforward to fix before merge. |
Code Review
High
The new let dupeID = baseURI.substring(
baseURI.indexOf('dupeid=') + 'dupeid='.length,
);
let mergeContact = currentID === dupeID;But the merge page URL is always constructed as (from
With
Fix: use let dupeID = new URL(baseURI).searchParams.get('dupeid') ?? '';Medium
The new deselect path calls Consequence: if the same link value is selected from both contacts and the user deselects one, the value is removed from Add a SummaryThe URL parsing bug means the merge-contact/primary-contact split logic never activates — link field merge-checkbox deselection is effectively broken. Both issues should be fixed before merge. |
|
@jlamanskygitt This is almost there. It's merging the values together well. Here are some kinda edge cases I found that we should handle.
Other than these, the merge seems to be working correctly and saves the updated value as expected. |
Code Review
Medium
The new case 'link': {
return !window.lodash.isEmpty(
$(td_field_input).find('dt-multi-text-groups').not('[value=""]'),
);
}
The case 'link': {
const fieldElement = $(td_field_input).find('dt-multi-text-groups')[0];
if (!fieldElement) return false;
const valueStr = fieldElement.getAttribute('value') || '[]';
try {
const arr = JSON.parse(valueStr);
return Array.isArray(arr) && arr.length > 0;
} catch (e) {
return false;
}
}SummaryNo new high-severity issues in this iteration. The one medium issue above is straightforward to fix. The blocking items flagged by earlier reviews (missing component, URL parsing, |
Code Review
High
The PR removes the // REMOVED:
$('.link-input').each((index, entry) => { ... });Unlike A generic web component loop equivalent to the one in Medium
In the new if (mergeContact) {
sourceItem.tempKey = sourceItem.meta_id; // mutates source object
sourceItem.meta_id = null; // mutates source object
mergedValue.push(sourceItem);
}
Sequence that breaks:
The fix is to clone before mutating: if (mergeContact) {
const newItem = { ...sourceItem, tempKey: sourceItem.meta_id, meta_id: null };
mergedValue.push(newItem);
}SummaryThe |
Implemented multi-text-groups changes for the theme