fix Link field dropdown not opening on focus when value is already set

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ali 2026-04-01 19:34:44 +04:00
parent aa9d5640c0
commit a9d18c05db
2 changed files with 19 additions and 0 deletions

View File

@ -14,6 +14,7 @@ app_include_js = [
"/assets/jey_erp/js/sales_invoice_vat.js",
"/assets/jey_erp/js/sales_order_vat.js",
"/assets/jey_erp/js/asset.js",
"/assets/jey_erp/js/link_field_fix.js",
]
app_include_css = [

View File

@ -0,0 +1,18 @@
// Fix: Link field dropdown should open on focus even when a value is already selected.
// Frappe core only triggers "input" (which opens the dropdown) when the field is empty.
// This patch makes it always trigger on focus.
$(document).ready(function () {
const OriginalLink = frappe.ui.form.ControlLink;
const originalMakeInput = OriginalLink.prototype.make_input;
OriginalLink.prototype.make_input = function () {
originalMakeInput.call(this);
// Replace the focus handler: always trigger "input" so dropdown opens
this.$input.off("focus").on("focus", () => {
this.$input.trigger("input");
this.show_link_and_clear_buttons();
});
};
});