#2895 - Bulk Edit - User Select Typeahead#2899
#2895 - Bulk Edit - User Select Typeahead#2899kodinkat wants to merge 6 commits intoDiscipleTools:developfrom
Conversation
kodinkat
commented
Mar 3, 2026
- fixes: Bulk Edit: User select typeahead #2895
…tions.js
- Removed legacy typeahead implementation for user selection in favor of the new dt-users-connection component, enhancing maintainability and user experience.
- Updated bulk edit field initialization to streamline user_select handling, ensuring compatibility with the new component structure.
- Adjusted display logic for user selection to support both legacy and new formats, improving flexibility in data handling.
- Enhanced SCSS to include styles for the new dt-users-connection component, ensuring consistent styling across the application.
PR Review: Bulk Edit - User Select TypeaheadGood direction overall. Removing ~113 net lines of custom typeahead wiring in favour of the existing A few items worth discussing before merge: Potential Bug: Value format mismatch in conditional removalIn After this PR the special-case branch in Please confirm what Potential Bug: Update payload formatThe same concern applies when a value is being set (not removed). For all non-special-cased field types the update payload builder falls into the generic else branch: updatePayload[fieldKey] = fieldValue;The DT backend's Minor:
|
- Introduced a new function, normalizeUserSelectValue, to standardize user selection values for backend compatibility.
- Updated bulk edit logic to utilize normalized user values for removal operations, improving data integrity and consistency.
- Enhanced handling of various input formats for user selection, ensuring robust processing of legacy and new data structures.
Code Review: #2895 - Bulk Edit - User Select TypeaheadThe overall direction is correct — replacing the custom typeahead with Critical Bug:
|
- Added support for number type user IDs, converting them to the format for consistency.
- Updated string handling to return null for invalid free-form strings, ensuring only valid payloads are processed for the backend user_select handler.
- Improved overall robustness in user selection value normalization, aligning with recent enhancements in user_select handling.
Code Review: PR 2899 - Bulk Edit User Select TypeaheadThe previous automated reviews flagged two critical bugs -- both appear to have been fixed in the current commit:
Round-trip confirmedTracing the full flow:
Conditional-removal in do_each() (lines 233-245) also works: the record value is extracted as fieldData['assigned-to'] (already in user-{id} format), and valueToRemove is now normalizedUserValueToRemove (also user-{id}), so strict equality holds. Minor: Object branch in normalizeUserSelectValue does not guard possibleId > 0The top-level number branch guards rawValue > 0 before building the user-N string, but the inner object branch does not apply the same guard when possibleId is a number. WordPress user IDs are always >= 1, so this is not a real-world risk, but mirroring the guard would be consistent. Minor: initializeBulkEditFieldHandlers is a comment-only no-opThe function body is entirely comments after this PR. If kept as an extension point a JSDoc would help signal intent. If it is genuinely dead code, removing it would be cleaner. Both prior automated reviews flagged this as well. Positive observations
Summary: The critical bugs from earlier in the review cycle have been addressed in the current commit. The two remaining notes are low-risk polish items. This looks safe to merge. |
|
@corsacca review ready.... |
| * ComponentService.convertValue(dt-users-connection), dt-users-connection.value, | ||
| * or legacy shapes. | ||
| */ | ||
| function normalizeUserSelectValue(rawValue) { |
There was a problem hiding this comment.
@kodinkat this looks like a whole lot of code handling maybes.
Can we double check the actual values being passed arround?
There was a problem hiding this comment.
@kodinkat, my question still stands. Why handle every single possible value, instead of pulling from what the component actually returns?
- Simplified the normalizeUserSelectValue function by removing legacy handling for arrays and objects, focusing on direct processing of user IDs.
- Updated documentation to clarify expected input formats, enhancing understanding of the function's behavior.
- Improved overall code readability and maintainability by streamlining the normalization logic.
…ools-theme into 2895-bulk-edit-user-select-typeahead
Code ReviewThis PR successfully replaces the legacy jQuery Typeahead implementation for Good
Questions / Minor Issues1. After the removal of the typeahead block the function body contains only a comment: function initializeBulkEditFieldHandlers(fieldKey, fieldType) {
// For all web components (including user_select via dt-users-connection), ...
// No per-field-type handlers are required at this time.
}It is still called from two places (lines 2126 and 2486). Either remove the function and its call sites, or leave a deliberate stub with the comment — just make sure the choice is intentional. Leaving an empty-but-called function is a mild code smell. 2. Dead branches in The new display code handles three shapes for if (Array.isArray(valuesToRemove)) { ... } // used when rawValueWithLabels is set
else if (typeof valuesToRemove === 'object') { ... } // never reached for user_select
else if (typeof valuesToRemove === 'string') { ... } // used when no component value
3. When This endpoint is designed for field option lookups. For
If 4. return `<dt-users-connection ${baseAttrs} single></dt-users-connection>`;
SummaryThe refactor is clean and the removal of ~120 lines of typeahead boilerplate is welcome. The main thing to confirm before merging is item #3 — that the |
…bulk.js to streamline code and improve maintainability.
Code Review: PR #2899 - Bulk Edit User Select TypeaheadThis is a clean refactor. Replacing the bespoke jQuery Typeahead lifecycle with Previous automated reviews surfaced two critical bugs (missing A few remaining items worth addressing before merge: Minor: unreachable branch in
|