aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickitem.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 82f4fac2bf..464076cbf8 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -4798,14 +4798,26 @@ void QQuickItem::forceActiveFocus()
void QQuickItem::forceActiveFocus(Qt::FocusReason reason)
{
+ Q_D(QQuickItem);
setFocus(true, reason);
QQuickItem *parent = parentItem();
+ QQuickItem *scope = nullptr;
while (parent) {
if (parent->flags() & QQuickItem::ItemIsFocusScope) {
parent->setFocus(true, reason);
+ if (!scope)
+ scope = parent;
}
parent = parent->parentItem();
}
+ // In certain reparenting scenarios, d->focus might be true and the scope
+ // might also have focus, so that setFocus() returns early without actually
+ // acquiring active focus, because it thinks it already has it. In that
+ // case, try to set the DeliveryAgent's active focus. (QTBUG-89736).
+ if (scope && !d->activeFocus) {
+ if (auto da = d->deliveryAgentPrivate())
+ da->setFocusInScope(scope, this, Qt::OtherFocusReason);
+ }
}
/*!