Skip to content

BAH 4610 | Migrated AutoComplete components family #35

Merged
ravinderkabli merged 13 commits into
masterfrom
BAH-4610
Apr 24, 2026
Merged

BAH 4610 | Migrated AutoComplete components family #35
ravinderkabli merged 13 commits into
masterfrom
BAH-4610

Conversation

@sahupadma

Copy link
Copy Markdown

JIRA - https://bahmni.atlassian.net/browse/BAH-4610

Migrated AutoComplete components family to bahmni-design-system Carbon Component.

Location and Provider used AutoComplete for rendering migrated that also.

@sahupadma sahupadma changed the title Bah 4610 BAH 4610 | Migrated AutoComplete components family Apr 24, 2026

@ravinderkabli ravinderkabli left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review for BAH-4610

Good foundation for the AutoComplete Carbon migration — the test suite is comprehensive (768 lines), the propsRef stale-closure pattern is correctly applied, and CarbonContainer wiring works for the main autocomplete / CodedControl path.

Found 4 blocking issue(s), 8 suggestion(s), and 1 nit(s).

Acceptance Criteria: 13/20 met, 5 partial, 2 missing (AC#6: fires undefined not null; AC#15: no onBlur).

Comment thread src/components/bahmni-design-system/CarbonContainer.jsx
invalid={hasError}
items={safeOptions.length > 0 ? safeOptions : safePropOptions}
itemToString={(item) => (item ? item[labelKey] || '' : '')}
initialSelectedItems={initialSelectedItems}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

blocking: Carbon FilterableMultiSelect only accepts initialSelectedItems as seed state — it does not respond to prop changes after mount. When propValue is cleared externally (form reset, AddMore row removal), setValue(propValue) runs but the widget stays unchanged. The single-select ComboBox correctly uses the controlled selectedItem prop.

Fix: add a key prop derived from the value identity (e.g. key={JSON.stringify(propValue)}) to force remount when the external value changes, or use MultiSelect if that version supports a controlled selectedItems prop.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

added

Comment thread src/components/bahmni-design-system/AutoComplete.jsx Outdated
Comment thread src/components/bahmni-design-system/AutoComplete.jsx Outdated
Comment thread src/components/bahmni-design-system/AutoComplete.jsx Outdated
);
}

if (asynchronous) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: No onBlur prop passed to ComboBox — AC #15 requires onBlur to fire when the user leaves the input. Carbon's ComboBox supports onBlur.

Fix: add onBlur: PropTypes.func to propTypes and pass onBlur={onBlur} on both ComboBox renders.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

added

Comment thread src/components/bahmni-design-system/Location.jsx
Comment thread src/components/bahmni-design-system/Location.jsx Outdated
const { properties } = this.props;
const isSearchable = (properties.style === 'autocomplete');
const minimumInput = isSearchable ? 2 : 0;
const isLoading = this.state.providerData.length === 0 && this.props.value;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: isLoading = this.state.providerData.length === 0 && this.props.value is true when the fetch fails (the catch block calls showNotification but never updates providerData). In edit mode with a pre-populated value, the spinner never stops and AutoComplete is never rendered.

Fix: add a loaded: false flag in state, set to true in both .then() and .catch(). Use isLoading = !this.state.loaded && this.props.value.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

added

setValue(undefined);
setHasError(hasErrors(errors));
if (onValueChange) {
onValueChange(undefined, errors);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: onValueChange(undefined, errors) — AC #6 specifies the clear callback fires with null. If any parent discriminates null vs undefined, clears will be mishandled.

Consider changing to onValueChange(null, errors) in both clear branches (here and line 180), or confirm with the team that undefined is acceptable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

done

@ravinderkabli ravinderkabli merged commit fdc07a4 into master Apr 24, 2026
2 checks passed
@ravinderkabli ravinderkabli deleted the BAH-4610 branch April 24, 2026 14:13
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.

3 participants