Skip to content

Commit

Permalink
fix: fix issue with widget not selecting place
Browse files Browse the repository at this point in the history
The issue with the widget not selecting a place was due to the event listener on blur. The blur event was happening before the "combobox-commit" event which is the one that sets the place. A fix for this was to add event listener to the `mousedown` event instead of the `click` event in the combobox code. That was solved with a patch using `patch-package`. Also mentioned in this issue: github/combobox-nav#54

Also fixed an issue that showed "undefined" if selected place did not have a locality.
  • Loading branch information
adriansberg committed Jan 5, 2024
1 parent 39727ba commit 2c82167
Show file tree
Hide file tree
Showing 19 changed files with 4,116 additions and 45 deletions.
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@atb-as/planner-web",
"version": "2.6.0",
"version": "2.8.0",
"private": true,
"license": "EUPL-1.2",
"scripts": {
Expand All @@ -18,7 +18,8 @@
"generate": "graphql-codegen",
"prestart": "yarn generate",
"predev": "yarn generate",
"generate-widget-version": "sh ./scripts/build-widget.sh"
"generate-widget-version": "sh ./scripts/build-widget.sh",
"postinstall": "patch-package"
},
"dependencies": {
"@apollo/client": "^3.8.8",
Expand Down Expand Up @@ -82,6 +83,8 @@
"graphql-tag": "^2.12.6",
"happy-dom": "^12.10.3",
"next-router-mock": "^0.9.10",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"prettier": "^3.1.1",
"rimraf": "^5.0.1",
"typescript": "5.3.3",
Expand Down
22 changes: 22 additions & 0 deletions patches/@github+combobox-nav+2.3.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/node_modules/@github/combobox-nav/dist/index.js b/node_modules/@github/combobox-nav/dist/index.js
index d86de71..3956688 100644
--- a/node_modules/@github/combobox-nav/dist/index.js
+++ b/node_modules/@github/combobox-nav/dist/index.js
@@ -34,7 +34,7 @@ export default class Combobox {
this.input.addEventListener('compositionend', this.compositionEventHandler);
this.input.addEventListener('input', this.inputHandler);
this.input.addEventListener('keydown', this.keyboardEventHandler);
- this.list.addEventListener('click', commitWithElement);
+ this.list.addEventListener('mousedown', commitWithElement);
this.indicateDefaultOption();
}
stop() {
@@ -44,7 +44,7 @@ export default class Combobox {
this.input.removeEventListener('compositionend', this.compositionEventHandler);
this.input.removeEventListener('input', this.inputHandler);
this.input.removeEventListener('keydown', this.keyboardEventHandler);
- this.list.removeEventListener('click', commitWithElement);
+ this.list.removeEventListener('mousedown', commitWithElement);
}
indicateDefaultOption() {
var _a;
1 change: 1 addition & 0 deletions public/widget/GYJwhgtkA/2.8.0/planner-web.css

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions public/widget/GYJwhgtkA/2.8.0/planner-web.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { GeocoderFeature } from '@atb/page-modules/departures';

export declare function createWidget({ urlBase, language, }: WidgetOptions): PlannerWebOutput;

declare type Languages = 'nb' | 'nn' | 'en';

export declare type PlannerWebOutput = {
output: string;
init: () => void;
urls: SettingConstants;
};

export declare function reverse(urlBase: string, coords: GeolocationCoordinates): Promise<GeocoderFeature | undefined>;

declare type SettingConstants = {
URL_BASE: string;
URL_JS_UMD: string;
URL_JS_ESM: string;
URL_CSS: string;
};

export declare type WidgetOptions = {
urlBase: string;
language?: Languages;
};

export { }
Loading

0 comments on commit 2c82167

Please sign in to comment.