@abgov/jsonforms-components 1.43.2 → 1.43.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.esm.js +11 -7
  2. package/package.json +1 -1
package/index.esm.js CHANGED
@@ -8001,6 +8001,7 @@ const AddressLookUpControl = props => {
8001
8001
  const [loading, setLoading] = useState(false);
8002
8002
  const [errors, setErrors] = useState({});
8003
8003
  const requiredFields = schema.required;
8004
+ const [dropdownSelected, setDropdownSelected] = useState(false);
8004
8005
  const updateFormData = updatedAddress => {
8005
8006
  setAddress(updatedAddress);
8006
8007
  handleChange(path, updatedAddress);
@@ -8009,6 +8010,9 @@ const AddressLookUpControl = props => {
8009
8010
  const dropdownRef = useRef(null);
8010
8011
  const handleInputChange = (field, value) => {
8011
8012
  var _a, _b;
8013
+ if (field === 'addressLine1' && searchTerm.length < 3) {
8014
+ setDropdownSelected(false);
8015
+ }
8012
8016
  let newAddress;
8013
8017
  const postalCodeErrorMessage = (_b = (_a = schema.errorMessage) === null || _a === void 0 ? void 0 : _a.properties) === null || _b === void 0 ? void 0 : _b.postalCode;
8014
8018
  if (field === 'postalCode') {
@@ -8035,7 +8039,7 @@ const AddressLookUpControl = props => {
8035
8039
  };
8036
8040
  useEffect(() => {
8037
8041
  const fetchSuggestions = () => __awaiter(void 0, void 0, void 0, function* () {
8038
- if (searchTerm.length > 2) {
8042
+ if (searchTerm.length > 2 && dropdownSelected === false) {
8039
8043
  setLoading(true);
8040
8044
  setOpen(true);
8041
8045
  yield fetchAddressSuggestions(formUrl, searchTerm, isAlbertaAddress).then(response => {
@@ -8053,7 +8057,7 @@ const AddressLookUpControl = props => {
8053
8057
  }
8054
8058
  });
8055
8059
  fetchSuggestions();
8056
- }, [searchTerm]);
8060
+ }, [searchTerm, dropdownSelected]);
8057
8061
  const handleDropdownChange = value => {
8058
8062
  setSearchTerm(value);
8059
8063
  handleInputChange('addressLine1', value);
@@ -8064,6 +8068,7 @@ const AddressLookUpControl = props => {
8064
8068
  handleChange(path, suggestAddress);
8065
8069
  setSuggestions([]);
8066
8070
  setErrors({});
8071
+ setDropdownSelected(true);
8067
8072
  };
8068
8073
  /* istanbul ignore next */
8069
8074
  const handleRequiredFieldBlur = name => {
@@ -8118,9 +8123,7 @@ const AddressLookUpControl = props => {
8118
8123
  ariaLabel: 'address-form-address1',
8119
8124
  placeholder: "Start typing the first line of your address, required.",
8120
8125
  value: (address === null || address === void 0 ? void 0 : address.addressLine1) || '',
8121
- onChange: (e, value) => {
8122
- handleDropdownChange(value);
8123
- },
8126
+ onChange: (e, value) => handleDropdownChange(value),
8124
8127
  onBlur: name => handleRequiredFieldBlur(name),
8125
8128
  width: "100%",
8126
8129
  onKeyPress: (e, value, key) => {
@@ -8132,10 +8135,9 @@ const AddressLookUpControl = props => {
8132
8135
  variant: "inline",
8133
8136
  size: "small",
8134
8137
  visible: true
8135
- }), suggestions && autocompletion && jsx("ul", {
8138
+ }), !loading && suggestions && autocompletion && jsx("ul", {
8136
8139
  ref: dropdownRef,
8137
8140
  className: "suggestions",
8138
- tabIndex: 0,
8139
8141
  children: suggestions && autocompletion && open && suggestions.map((suggestion, index) => jsx(ListItem, {
8140
8142
  "data-index": index,
8141
8143
  onMouseDown: e => {
@@ -8341,6 +8343,7 @@ const NameInputs = ({
8341
8343
  return jsxs(GoAGrid, {
8342
8344
  minChildWidth: "0ch",
8343
8345
  gap: "s",
8346
+ mb: "m",
8344
8347
  testId: "wrapper",
8345
8348
  children: [jsx(GoAFormItem, {
8346
8349
  testId: "formitem-first-name",
@@ -8557,6 +8560,7 @@ const FullNameDobControl = props => {
8557
8560
  children: [jsxs(GoAGrid, {
8558
8561
  minChildWidth: "0ch",
8559
8562
  gap: "s",
8563
+ mb: "m",
8560
8564
  children: [jsx(GoAFormItem, {
8561
8565
  label: "First name",
8562
8566
  requirement: ((_a = schema === null || schema === void 0 ? void 0 : schema.required) === null || _a === void 0 ? void 0 : _a.includes('firstName')) ? 'required' : undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abgov/jsonforms-components",
3
- "version": "1.43.2",
3
+ "version": "1.43.3",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Government of Alberta - React renderers for JSON Forms based on the design system.",
6
6
  "repository": "https://github.com/GovAlta/adsp-monorepo",