From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit 07/11] Toolkit: update focusJump override
Date: Wed, 26 May 2021 10:58:35 +0200 [thread overview]
Message-ID: <20210526085839.9808-8-d.csapak@proxmox.com> (raw)
In-Reply-To: <20210526085839.9808-1-d.csapak@proxmox.com>
upstream code changed a bit, update to current version
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/Toolkit.js | 121 ++++++++++++++++++++++++++++++++++---------------
1 file changed, 84 insertions(+), 37 deletions(-)
diff --git a/src/Toolkit.js b/src/Toolkit.js
index 517f1a1..b85cd32 100644
--- a/src/Toolkit.js
+++ b/src/Toolkit.js
@@ -380,58 +380,105 @@ Ext.define(null, {
jumpToFocus: false,
saveFocusState: function() {
- let me = this,
+ var me = this,
store = me.dataSource,
actionableMode = me.actionableMode,
navModel = me.getNavigationModel(),
focusPosition = actionableMode ? me.actionPosition : navModel.getPosition(true),
- refocusRow, refocusCol;
-
- if (focusPosition) {
+ activeElement = Ext.fly(Ext.Element.getActiveElement()),
+ focusCell = focusPosition && focusPosition.view === me &&
+ Ext.fly(focusPosition.getCell(true)),
+ refocusRow, refocusCol, record;
+
+ // The navModel may return a position that is in a locked partner, so check that
+ // the focusPosition's cell contains the focus before going forward.
+ // The skipSaveFocusState is set by Actionables which actively control
+ // focus destination. See CellEditing#activateCell.
+ if (!me.skipSaveFocusState && focusCell && focusCell.contains(activeElement)) {
// Separate this from the instance that the nav model is using.
focusPosition = focusPosition.clone();
- // Exit actionable mode.
- // We must inform any Actionables that they must relinquish control.
- // Tabbability must be reset.
- if (actionableMode) {
- me.ownerGrid.setActionableMode(false);
+ // While we deactivate the focused element, suspend focus processing on it.
+ activeElement.suspendFocusEvents();
+
+ // Suspend actionable mode.
+ // Each Actionable must silently save its state ready to resume when focus
+ // can be restored but should only do that if the activeElement is not the cell itself,
+ // this happens when the grid is refreshed while one of the actionables is being
+ // deactivated (e.g. Calling view refresh inside CellEditor 'edit' event listener).
+ if (actionableMode && focusCell.dom !== activeElement.dom) {
+ me.suspendActionableMode();
+ } else {
+ // Clear position, otherwise the setPosition on the other side
+ // will be rejected as a no-op if the resumption position is logically
+ // equivalent.
+ actionableMode = false;
+ navModel.setPosition();
}
- // Blur the focused descendant, but do not trigger focusLeave.
- me.el.dom.focus();
+ // Do not leave the element in tht state in case refresh fails, and restoration
+ // closure not called.
+ activeElement.resumeFocusEvents();
- // Exiting actionable mode navigates to the owning cell, so in either focus mode we must
- // clear the navigation position
- navModel.setPosition();
+ // if the store is expanding or collapsing, we should never scroll the view.
+ if (store.isExpandingOrCollapsing) {
+ return Ext.emptyFn;
+ }
// The following function will attempt to refocus back in the same mode to the same cell
- // as it was at before based upon the previous record (if it's still inthe store), or the row index.
+ // as it was at before based upon the previous record (if it's still in the store),
+ // or the row index.
return function() {
+ var all;
+
+ // May have changed due to reconfigure
+ store = me.dataSource;
+
// If we still have data, attempt to refocus in the same mode.
if (store.getCount()) {
- // Adjust expectations of where we are able to refocus according to what kind of destruction
- // might have been wrought on this view's DOM during focus save.
- refocusRow = Math.min(focusPosition.rowIdx, me.all.getCount() - 1);
- refocusCol = Math.min(focusPosition.colIdx,
- me.getVisibleColumnManager().getColumns().length - 1);
- refocusRow = store.contains(focusPosition.record) ? focusPosition.record : refocusRow;
- focusPosition = new Ext.grid.CellContext(me).setPosition(refocusRow, refocusCol);
-
- if (actionableMode) {
- me.ownerGrid.setActionableMode(true, focusPosition);
- } else {
- me.cellFocused = true;
-
- // we sometimes want to scroll back to where we were
- let x = me.getScrollX();
- let y = me.getScrollY();
-
- // Pass "preventNavigation" as true so that that does not cause selection.
- navModel.setPosition(focusPosition, null, null, null, true);
-
- if (!me.jumpToFocus) {
- me.scrollTo(x, y);
+ all = me.all;
+
+ // Adjust expectations of where we are able to refocus according to
+ // what kind of destruction might have been wrought on this view's DOM
+ // during focus save.
+ refocusRow =
+ Math.min(Math.max(focusPosition.rowIdx, all.startIndex), all.endIndex);
+
+ refocusCol = Math.min(
+ focusPosition.colIdx,
+ me.getVisibleColumnManager().getColumns().length - 1,
+ );
+
+ record = focusPosition.record;
+
+ focusPosition = new Ext.grid.CellContext(me).setPosition(
+ record && store.contains(record) && !record.isCollapsedPlaceholder
+ ? record
+ : refocusRow,
+ refocusCol,
+ );
+
+ // Maybe there are no cells. eg: all groups collapsed.
+ if (focusPosition.getCell(true)) {
+ if (actionableMode) {
+ me.resumeActionableMode(focusPosition);
+ } else {
+ // we sometimes want to scroll back to where we are
+
+ let x = me.getScrollX();
+ let y = me.getScrollY();
+
+ // Pass "preventNavigation" as true
+ // so that that does not cause selection.
+ navModel.setPosition(focusPosition, null, null, null, true);
+
+ if (!navModel.getPosition()) {
+ focusPosition.column.focus();
+ }
+
+ if (!me.jumpToFocus) {
+ me.scrollTo(x, y);
+ }
}
}
} else { // No rows - focus associated column header
--
2.20.1
next prev parent reply other threads:[~2021-05-26 8:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-26 8:58 [pve-devel] [PATCH widget-toolkit 00/11] fixes/preparation for extjs7.0 Dominik Csapak
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 01/11] data/ProxmoxProxy: set responseType to undefined for XMLHTTPRequest Dominik Csapak
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 02/11] Toolkit: set download url for draw containers to '-' Dominik Csapak
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 03/11] Toolkit: set clearPropertiesOnDestroy to false by default Dominik Csapak
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 04/11] css: add css changes for treelist Dominik Csapak
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 05/11] panel/RRDChart: fix legend/undoZoom Dominik Csapak
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 06/11] Toolkit: update overrides for scroll fixes Dominik Csapak
2021-05-26 8:58 ` Dominik Csapak [this message]
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 08/11] Toolkit: remove firefox touchscreen override Dominik Csapak
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 09/11] Toolkit: remove pie chart fix Dominik Csapak
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 10/11] Toolkit: remove textarea fix Dominik Csapak
2021-05-26 8:58 ` [pve-devel] [PATCH widget-toolkit 11/11] Toolkit: remove Datepicker fix Dominik Csapak
2021-05-28 8:43 ` [pve-devel] applied: [PATCH widget-toolkit 00/11] fixes/preparation for extjs7.0 Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210526085839.9808-8-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox