Skip to content

Multi text groups#2893

Open
jlamanskygitt wants to merge 6 commits intoDiscipleTools:developfrom
jlamanskygitt:multi-text-groups
Open

Multi text groups#2893
jlamanskygitt wants to merge 6 commits intoDiscipleTools:developfrom
jlamanskygitt:multi-text-groups

Conversation

@jlamanskygitt
Copy link
Contributor

Implemented multi-text-groups changes for the theme

@cairocoder01
Copy link
Collaborator

@jlamanskygitt It looks like you created a new field type for this component. It should actually be used for the existing link field type and just replace that existing UI.

@cairocoder01 cairocoder01 self-assigned this Feb 19, 2026
<div class="input-group">
<input
type="text"
class="link-input input-group-field"
Copy link
Collaborator

Choose a reason for hiding this comment

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

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.

@github-actions
Copy link

github-actions bot commented Mar 4, 2026

Code Review

Thanks for this refactor! Moving the link field rendering into the DT_Components class and using the dt-multi-text-groups web component is the right direction and aligns well with how other field types (e.g., communication_channel, key_select, multi_select) are already handled. The overall structure is clean and consistent with existing patterns.

Bug: Deleted options not filtered

The original code explicitly skipped options marked as deleted:

if ( isset( $option_value['deleted'] ) && $option_value['deleted'] === true ) {
    continue;
}

The new render_link() method's array_map does not replicate this filter, so deleted link types will appear in the groups attribute passed to dt-multi-text-groups. This should be fixed, for example by filtering before mapping:

$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 options

The original dropdown rendered per-option icons via dt_render_field_icon( $option_value ). The new $options_array only includes id and label. If the dt-multi-text-groups component supports an icon property per group, it should be included here to maintain visual parity with the previous UI:

'icon' => $value['icon'] ?? null,

Minor: array_map closure style

The other render_* methods in DT_Components (e.g., render_key_select, render_multi_select) use the same two-arg array_map pattern for building options arrays with array_keys / values. This is consistent — no change needed.

Summary

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 ⚠️ Likely regression — per-option icons not passed through
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.

@cairocoder01
Copy link
Collaborator

Functionally, this looks great. Really nice work! Just waiting on the cleanup of the old code.

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

Code Review

Thanks for working on migrating the link field to the web components pattern. The approach of using DT_Components::render_link() is consistent with how other field types (communication_channel, connection, etc.) have been migrated. However, there are several issues to address before this is ready to merge.


Critical: Missing web component

The new render_link() method renders a <dt-multi-text-groups> component, but this component does not exist anywhere in the codebase or in @disciple.tools/web-components. A search across all JS, PHP, and TS files returns zero matches for dt-multi-text-groups.

This means link fields will not render at all after this PR is merged. Is this component being developed in a separate PR against disciple-tools-web-components? If so, this theme PR should not merge until that dependency is available and the component is included in the build.


Bug: Deleted link options not filtered

The original code explicitly skipped options marked as deleted:

if ( isset( $option_value['deleted'] ) && $option_value['deleted'] === true ) {
    continue;
}

The new render_link() passes all options to the component without filtering:

$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 dt-multi-text-groups handles this filtering internally — if so, it needs to receive the deleted flag in the options array so it can act on it.


Bug: Missing null check on default key

$default_options = $fields[$field_key]['default'];

If the field definition does not have a default key this will produce a PHP notice/warning. The safer approach:

$default_options = $fields[$field_key]['default'] ?? [];

Orphaned JavaScript code

The PR removes the link cases from merge/new-record logic, but several dead code blocks remain and should be cleaned up in this PR:

shared-functions.jsSHAREDFUNCTIONS.addLink() (around line 942) targets .link-list-* and #link-template-* DOM elements that no longer exist after the PHP rendering changes.

details.js — Event handlers for .add-link-dropdown[data-only-one-option] and .add-link__option (lines ~314-322) reference the old HTML structure.

new-record.js — The fieldType === 'link' branch (lines ~84-100) that shows/hides .add-link-${field} and binds addLink handlers references the old DOM structure.

new-bulk-record.js — Same pattern as new-record.js (lines ~57-62, ~79-87).

merge-post-details.jsis_link_field_value_already_in_primary() (around line 1199) is no longer called anywhere after the case 'link' blocks are removed, but the function definition remains.


Orphaned SCSS

The link field styles in dt-assets/scss/_details.scss.add-link-dropdown, .add-link-dropdown__content, .add-link__option, .link-section, .link-section .section-subheader, etc. — are no longer needed and should be removed.


Minor: Icon not forwarded in options array

The original code rendered per-type icons. The new $options_array only includes id and label. If dt-multi-text-groups renders per-type icons, the icon key should be forwarded:

return [
    'id' => (string) $key,
    'label' => $value['label'] ?? $key,
    'icon' => $value['icon'] ?? null,
];

Summary

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants