diff --git a/app/assets/javascripts/discourse/app/components/d-button.gjs b/app/assets/javascripts/discourse/app/components/d-button.gjs index dcfd972ef9e..5dcaf8b633d 100644 --- a/app/assets/javascripts/discourse/app/components/d-button.gjs +++ b/app/assets/javascripts/discourse/app/components/d-button.gjs @@ -19,6 +19,7 @@ const ACTION_AS_STRING_DEPRECATION_ARGS = [ export default class DButton extends GlimmerComponentWithDeprecatedParentView { @service router; + @service capabilities; @notEmpty("args.icon") btnIcon; @@ -114,6 +115,7 @@ export default class DButton extends GlimmerComponentWithDeprecatedParentView { _triggerAction(event) { const { action: actionVal, route, routeModels } = this.args; + const isIOS = this.capabilities?.isIOS; if (actionVal || route) { if (actionVal) { @@ -129,19 +131,35 @@ export default class DButton extends GlimmerComponentWithDeprecatedParentView { ); } } else if (typeof actionVal === "object" && actionVal.value) { - // Using `next()` to optimise INP - next(() => + if (isIOS) { + // Don't optimise INP in iOS + // it results in focus events not being triggered forwardEvent ? actionVal.value(actionParam, event) - : actionVal.value(actionParam) - ); + : actionVal.value(actionParam); + } else { + // Using `next()` to optimise INP + next(() => + forwardEvent + ? actionVal.value(actionParam, event) + : actionVal.value(actionParam) + ); + } } else if (typeof actionVal === "function") { - // Using `next()` to optimise INP - next(() => + if (isIOS) { + // Don't optimise INP in iOS + // it results in focus events not being triggered forwardEvent ? actionVal(actionParam, event) - : actionVal(actionParam) - ); + : actionVal(actionParam); + } else { + // Using `next()` to optimise INP + next(() => + forwardEvent + ? actionVal(actionParam, event) + : actionVal(actionParam) + ); + } } } else if (route) { if (routeModels) {