DEV: Do not delay DButton actions on iOS (#30322)

Followup to #28019, on iOS this delay means that we don't properly set
focus on the composer.
This commit is contained in:
Penar Musaraj 2024-12-17 11:57:15 -05:00 committed by GitHub
parent 415abe6491
commit bcff64b9ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 26 additions and 8 deletions

View File

@ -19,6 +19,7 @@ const ACTION_AS_STRING_DEPRECATION_ARGS = [
export default class DButton extends GlimmerComponentWithDeprecatedParentView { export default class DButton extends GlimmerComponentWithDeprecatedParentView {
@service router; @service router;
@service capabilities;
@notEmpty("args.icon") btnIcon; @notEmpty("args.icon") btnIcon;
@ -114,6 +115,7 @@ export default class DButton extends GlimmerComponentWithDeprecatedParentView {
_triggerAction(event) { _triggerAction(event) {
const { action: actionVal, route, routeModels } = this.args; const { action: actionVal, route, routeModels } = this.args;
const isIOS = this.capabilities?.isIOS;
if (actionVal || route) { if (actionVal || route) {
if (actionVal) { if (actionVal) {
@ -129,13 +131,28 @@ export default class DButton extends GlimmerComponentWithDeprecatedParentView {
); );
} }
} else if (typeof actionVal === "object" && actionVal.value) { } else if (typeof actionVal === "object" && actionVal.value) {
if (isIOS) {
// Don't optimise INP in iOS
// it results in focus events not being triggered
forwardEvent
? actionVal.value(actionParam, event)
: actionVal.value(actionParam);
} else {
// Using `next()` to optimise INP // Using `next()` to optimise INP
next(() => next(() =>
forwardEvent forwardEvent
? actionVal.value(actionParam, event) ? actionVal.value(actionParam, event)
: actionVal.value(actionParam) : actionVal.value(actionParam)
); );
}
} else if (typeof actionVal === "function") { } else if (typeof actionVal === "function") {
if (isIOS) {
// Don't optimise INP in iOS
// it results in focus events not being triggered
forwardEvent
? actionVal(actionParam, event)
: actionVal(actionParam);
} else {
// Using `next()` to optimise INP // Using `next()` to optimise INP
next(() => next(() =>
forwardEvent forwardEvent
@ -143,6 +160,7 @@ export default class DButton extends GlimmerComponentWithDeprecatedParentView {
: actionVal(actionParam) : actionVal(actionParam)
); );
} }
}
} else if (route) { } else if (route) {
if (routeModels) { if (routeModels) {
const routeModelsArray = Array.isArray(routeModels) const routeModelsArray = Array.isArray(routeModels)