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:
parent
415abe6491
commit
bcff64b9ab
|
@ -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,19 +131,35 @@ export default class DButton extends GlimmerComponentWithDeprecatedParentView {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (typeof actionVal === "object" && actionVal.value) {
|
} else if (typeof actionVal === "object" && actionVal.value) {
|
||||||
// Using `next()` to optimise INP
|
if (isIOS) {
|
||||||
next(() =>
|
// Don't optimise INP in iOS
|
||||||
|
// it results in focus events not being triggered
|
||||||
forwardEvent
|
forwardEvent
|
||||||
? actionVal.value(actionParam, event)
|
? 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") {
|
} else if (typeof actionVal === "function") {
|
||||||
// Using `next()` to optimise INP
|
if (isIOS) {
|
||||||
next(() =>
|
// Don't optimise INP in iOS
|
||||||
|
// it results in focus events not being triggered
|
||||||
forwardEvent
|
forwardEvent
|
||||||
? actionVal(actionParam, event)
|
? actionVal(actionParam, event)
|
||||||
: actionVal(actionParam)
|
: actionVal(actionParam);
|
||||||
);
|
} else {
|
||||||
|
// Using `next()` to optimise INP
|
||||||
|
next(() =>
|
||||||
|
forwardEvent
|
||||||
|
? actionVal(actionParam, event)
|
||||||
|
: actionVal(actionParam)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (route) {
|
} else if (route) {
|
||||||
if (routeModels) {
|
if (routeModels) {
|
||||||
|
|
Loading…
Reference in New Issue