mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
22 lines
541 B
JavaScript
22 lines
541 B
JavaScript
|
import { Controller } from "@hotwired/stimulus";
|
||
|
|
||
|
// Connects to data-controller="focus-record"
|
||
|
export default class extends Controller {
|
||
|
static values = {
|
||
|
id: String,
|
||
|
};
|
||
|
|
||
|
connect() {
|
||
|
const element = document.getElementById(this.idValue);
|
||
|
|
||
|
if (element) {
|
||
|
element.scrollIntoView({ behavior: "smooth" });
|
||
|
|
||
|
// Remove the focused_record_id parameter from URL
|
||
|
const url = new URL(window.location);
|
||
|
url.searchParams.delete("focused_record_id");
|
||
|
window.history.replaceState({}, "", url);
|
||
|
}
|
||
|
}
|
||
|
}
|