Spaces:
Running
Running
Upload 个人中心视图.js
Browse files- 前端页面/profile/个人中心视图.js +11 -0
前端页面/profile/个人中心视图.js
CHANGED
|
@@ -143,6 +143,10 @@ export function showUserProfile(initialUserData, currentUser = null, isMe = true
|
|
| 143 |
|
| 144 |
function render() {
|
| 145 |
if (!scope.isCurrent()) return;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 146 |
releaseChild();
|
| 147 |
const generation = ++renderGeneration;
|
| 148 |
const current = () => scope.isCurrent() && renderGeneration === generation;
|
|
@@ -295,6 +299,13 @@ export function showUserProfile(initialUserData, currentUser = null, isMe = true
|
|
| 295 |
listDOM._profileAddCleanup = cleanup => scope.addCleanup(cleanup);
|
| 296 |
renderProfileListContent(activeTab, listDOM, userData, currentUser, openOtherUserProfileModal);
|
| 297 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 298 |
}
|
| 299 |
|
| 300 |
container.updateData = function(newUserData) {
|
|
|
|
| 143 |
|
| 144 |
function render() {
|
| 145 |
if (!scope.isCurrent()) return;
|
| 146 |
+
const focused = document.activeElement;
|
| 147 |
+
const ownedFocus = document.hasFocus() && container.contains(focused);
|
| 148 |
+
const focusedTab = ownedFocus && focused.matches('.profile-tab-btn') ? focused.dataset.id : null;
|
| 149 |
+
const focusedCount = ownedFocus && ['btn-followers', 'btn-following'].includes(focused.id) ? focused.id : null;
|
| 150 |
releaseChild();
|
| 151 |
const generation = ++renderGeneration;
|
| 152 |
const current = () => scope.isCurrent() && renderGeneration === generation;
|
|
|
|
| 299 |
listDOM._profileAddCleanup = cleanup => scope.addCleanup(cleanup);
|
| 300 |
renderProfileListContent(activeTab, listDOM, userData, currentUser, openOtherUserProfileModal);
|
| 301 |
}
|
| 302 |
+
if ((focusedTab || focusedCount) && current() && container.isConnected
|
| 303 |
+
&& document.hasFocus() && document.activeElement === document.body) {
|
| 304 |
+
const target = focusedTab
|
| 305 |
+
? [...container.querySelectorAll('.profile-tab-btn')].find(button => button.dataset.id === focusedTab)
|
| 306 |
+
: container.querySelector('#' + focusedCount);
|
| 307 |
+
if (target && !target.disabled && target.getClientRects().length) target.focus({ preventScroll: true });
|
| 308 |
+
}
|
| 309 |
}
|
| 310 |
|
| 311 |
container.updateData = function(newUserData) {
|