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 {
@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) {