diff --git a/client/src/controllers/LinkController.ts b/client/src/controllers/LinkController.ts
index b1f928c7a2d1..6594c61deffc 100644
--- a/client/src/controllers/LinkController.ts
+++ b/client/src/controllers/LinkController.ts
@@ -1,5 +1,13 @@
import { Controller } from '@hotwired/stimulus';
+/**
+ * Adds the ability for the controlled element to reflect the URL's query parameters
+ * from an event or the current URL into the window.location so that dynamic updates
+ * to listings can be available on refreshing or other internal links.
+ *
+ * @example - Reflecting the URL's query parameters
+ *
+ */
export class LinkController extends Controller {
static values = {
attrName: { default: 'href', type: String },
@@ -7,8 +15,11 @@ export class LinkController extends Controller {
reflectKeys: { default: ['__all__'], type: Array },
};
+ /** Attribute on the controlled element containing the URL string. */
declare attrNameValue: string;
+ /** URL param keys that will be kept in the current location's URL. */
declare preserveKeysValue: string[];
+ /** URL param keys to be added to the location URL from the source URL. */
declare reflectKeysValue: string[];
get url() {
@@ -59,14 +70,16 @@ export class LinkController extends Controller {
this.element.setAttribute(this.attrNameValue, currentUrl.toString());
}
- setParams(e?: CustomEvent<{ requestUrl?: string }>) {
- if (!e) {
+ setParams(event?: CustomEvent<{ requestUrl?: string }>) {
+ if (!event) {
this.setParamsFromURL(new URL(window.location.href));
return;
}
- if (!e.detail?.requestUrl) return;
+ if (!event.detail?.requestUrl) return;
- this.setParamsFromURL(new URL(e.detail.requestUrl, window.location.href));
+ this.setParamsFromURL(
+ new URL(event.detail.requestUrl, window.location.href),
+ );
}
}
diff --git a/client/src/controllers/SwapController.ts b/client/src/controllers/SwapController.ts
index 07faa6379303..250f844b2be7 100644
--- a/client/src/controllers/SwapController.ts
+++ b/client/src/controllers/SwapController.ts
@@ -45,8 +45,8 @@ export class SwapController extends Controller<
static values = {
icon: { default: '', type: String },
loading: { default: false, type: Boolean },
- src: { default: '', type: String },
reflect: { default: false, type: Boolean },
+ src: { default: '', type: String },
target: { default: '#listing-results', type: String },
wait: { default: 200, type: Number },
};
@@ -58,8 +58,8 @@ export class SwapController extends Controller<
declare iconValue: string;
declare loadingValue: boolean;
- declare srcValue: string;
declare reflectValue: boolean;
+ declare srcValue: string;
declare targetValue: string;
declare waitValue: number;