Skip to content

Commit

Permalink
fix(country/county): Fix update country/county combobox selector
Browse files Browse the repository at this point in the history
  • Loading branch information
mfilip committed May 17, 2024
1 parent dde98f9 commit 1bbb621
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ window.IdealPostcodes.PostcodeLookup = PostcodeLookup;
const isSupported = (c: string | null): boolean =>
["GB", "IM", "JE", "GG"].indexOf(c || "") !== -1;

const isDiv = (e: HTMLElement | null): e is HTMLDivElement => {
if (e === null) return false;
return (
e instanceof HTMLDivElement || e.constructor.name === "HTMLDivElement"
);
};

interface Result {
selectContainer: HTMLElement;
context: HTMLElement;
Expand Down Expand Up @@ -248,9 +255,12 @@ export const newBind = (selectors: Selectors, blocks: boolean = false) => (confi
if (isString(outputFields.country)) {
const countryField = toHtmlElem(parent, outputFields.country);
//@ts-expect-error
const county = toHtmlElem(parent, outputFields.county);
let county = toHtmlElem(parent, outputFields.county);
if(isDiv(county)) {
county = county.querySelector("input");
}
//in case input is readonly when enforced country by owner
if(countryField && isInput(countryField)) {
if(countryField && isInput(countryField) && countryField.getAttribute("readonly") !== null) {
update(countryField, address.country_iso_2);
}

Expand All @@ -260,6 +270,8 @@ export const newBind = (selectors: Selectors, blocks: boolean = false) => (confi
if(county) {
if (isInput(county)) {
update(county, address.county);
//@ts-expect-error
county?.parentElement?.parentElement?.nextSibling?.firstChild.click();
} else {
//@ts-expect-error
update(county, address.county_code);
Expand Down
5 changes: 4 additions & 1 deletion uk-address-postcode-validation/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,12 @@ Prices range between 2 and 2.5p per lookup, with alternate pricing options avail

== Changelog ==

= 3.5.2 =
= 3.5.3 =
* Recompile JavaScript packages

= 3.5.2 =
* Fix issue country and county selector combobox search

= 3.5.1 =
* Fix issue with country selection for certain country input fields

Expand Down

0 comments on commit 1bbb621

Please sign in to comment.