|
28 | 28 | <h2>{{ error }}</h2> |
29 | 29 | </div> |
30 | 30 |
|
31 | | - <template v-if="!showSharingDetailsView"> |
32 | | - <!-- shares content --> |
33 | | - <div class="sharingTab__content"> |
34 | | - <!-- shared with me information --> |
35 | | - <ul> |
36 | | - <SharingEntrySimple v-if="isSharedWithMe" v-bind="sharedWithMe" class="sharing-entry__reshare"> |
37 | | - <template #avatar> |
38 | | - <NcAvatar :user="sharedWithMe.user" |
39 | | - :display-name="sharedWithMe.displayName" |
40 | | - class="sharing-entry__avatar" /> |
41 | | - </template> |
42 | | - </SharingEntrySimple> |
43 | | - </ul> |
44 | | - |
45 | | - <!-- add new share input --> |
46 | | - <SharingInput v-if="!loading" |
47 | | - :can-reshare="canReshare" |
48 | | - :file-info="fileInfo" |
49 | | - :link-shares="linkShares" |
50 | | - :reshare="reshare" |
51 | | - :shares="shares" |
52 | | - @open-sharing-details="toggleShareDetailsView" /> |
53 | | - |
54 | | - <!-- link shares list --> |
55 | | - <SharingLinkList v-if="!loading" |
56 | | - ref="linkShareList" |
57 | | - :can-reshare="canReshare" |
58 | | - :file-info="fileInfo" |
59 | | - :shares="linkShares" |
60 | | - @open-sharing-details="toggleShareDetailsView" /> |
61 | | - |
62 | | - <!-- other shares list --> |
63 | | - <SharingList v-if="!loading" |
64 | | - ref="shareList" |
65 | | - :shares="shares" |
66 | | - :file-info="fileInfo" |
67 | | - @open-sharing-details="toggleShareDetailsView" /> |
68 | | - |
69 | | - <!-- inherited shares --> |
70 | | - <SharingInherited v-if="canReshare && !loading" :file-info="fileInfo" /> |
71 | | - |
72 | | - <!-- internal link copy --> |
73 | | - <SharingEntryInternal :file-info="fileInfo" /> |
74 | | - |
75 | | - <!-- projects --> |
76 | | - <CollectionList v-if="projectsEnabled && fileInfo" |
77 | | - :id="`${fileInfo.id}`" |
78 | | - type="file" |
79 | | - :name="fileInfo.name" /> |
80 | | - </div> |
81 | | - |
82 | | - <!-- additional entries, use it with cautious --> |
83 | | - <div v-for="(section, index) in sections" |
84 | | - :ref="'section-' + index" |
85 | | - :key="index" |
86 | | - class="sharingTab__additionalContent"> |
87 | | - <component :is="section($refs['section-'+index], fileInfo)" :file-info="fileInfo" /> |
88 | | - </div> |
89 | | - </template> |
| 31 | + <!-- shares content --> |
| 32 | + <div v-show="!showSharingDetailsView" |
| 33 | + class="sharingTab__content"> |
| 34 | + <!-- shared with me information --> |
| 35 | + <ul> |
| 36 | + <SharingEntrySimple v-if="isSharedWithMe" v-bind="sharedWithMe" class="sharing-entry__reshare"> |
| 37 | + <template #avatar> |
| 38 | + <NcAvatar :user="sharedWithMe.user" |
| 39 | + :display-name="sharedWithMe.displayName" |
| 40 | + class="sharing-entry__avatar" /> |
| 41 | + </template> |
| 42 | + </SharingEntrySimple> |
| 43 | + </ul> |
| 44 | + |
| 45 | + <!-- add new share input --> |
| 46 | + <SharingInput v-if="!loading" |
| 47 | + :can-reshare="canReshare" |
| 48 | + :file-info="fileInfo" |
| 49 | + :link-shares="linkShares" |
| 50 | + :reshare="reshare" |
| 51 | + :shares="shares" |
| 52 | + @open-sharing-details="toggleShareDetailsView" /> |
| 53 | + |
| 54 | + <!-- link shares list --> |
| 55 | + <SharingLinkList v-if="!loading" |
| 56 | + ref="linkShareList" |
| 57 | + :can-reshare="canReshare" |
| 58 | + :file-info="fileInfo" |
| 59 | + :shares="linkShares" |
| 60 | + @open-sharing-details="toggleShareDetailsView" /> |
| 61 | + |
| 62 | + <!-- other shares list --> |
| 63 | + <SharingList v-if="!loading" |
| 64 | + ref="shareList" |
| 65 | + :shares="shares" |
| 66 | + :file-info="fileInfo" |
| 67 | + @open-sharing-details="toggleShareDetailsView" /> |
| 68 | + |
| 69 | + <!-- inherited shares --> |
| 70 | + <SharingInherited v-if="canReshare && !loading" :file-info="fileInfo" /> |
| 71 | + |
| 72 | + <!-- internal link copy --> |
| 73 | + <SharingEntryInternal :file-info="fileInfo" /> |
| 74 | + |
| 75 | + <!-- projects --> |
| 76 | + <CollectionList v-if="projectsEnabled && fileInfo" |
| 77 | + :id="`${fileInfo.id}`" |
| 78 | + type="file" |
| 79 | + :name="fileInfo.name" /> |
| 80 | + </div> |
| 81 | + |
| 82 | + <!-- additional entries, use it with cautious --> |
| 83 | + <div v-for="(section, index) in sections" |
| 84 | + v-show="!showSharingDetailsView" |
| 85 | + :ref="'section-' + index" |
| 86 | + :key="index" |
| 87 | + class="sharingTab__additionalContent"> |
| 88 | + <component :is="section($refs['section-'+index], fileInfo)" :file-info="fileInfo" /> |
| 89 | + </div> |
90 | 90 |
|
91 | 91 | <!-- share details --> |
92 | | - <SharingDetailsTab v-else :file-info="shareDetailsData.fileInfo" |
| 92 | + <SharingDetailsTab v-if="showSharingDetailsView" |
| 93 | + :file-info="shareDetailsData.fileInfo" |
93 | 94 | :share="shareDetailsData.share" |
94 | 95 | @close-sharing-details="toggleShareDetailsView" |
95 | 96 | @add:share="addShare" |
@@ -154,6 +155,7 @@ export default { |
154 | 155 | projectsEnabled: loadState('core', 'projects_enabled', false), |
155 | 156 | showSharingDetailsView: false, |
156 | 157 | shareDetailsData: {}, |
| 158 | + returnFocusElement: null, |
157 | 159 | } |
158 | 160 | }, |
159 | 161 |
|
@@ -389,11 +391,31 @@ export default { |
389 | 391 | } |
390 | 392 | }) |
391 | 393 | }, |
| 394 | +
|
392 | 395 | toggleShareDetailsView(eventData) { |
| 396 | + if (!this.showSharingDetailsView) { |
| 397 | + const isAction = Array.from(document.activeElement.classList) |
| 398 | + .some(className => className.startsWith('action-')) |
| 399 | + if (isAction) { |
| 400 | + const menuId = document.activeElement.closest('[role="menu"]')?.id |
| 401 | + this.returnFocusElement = document.querySelector(`[aria-controls="${menuId}"]`) |
| 402 | + } else { |
| 403 | + this.returnFocusElement = document.activeElement |
| 404 | + } |
| 405 | + } |
| 406 | +
|
393 | 407 | if (eventData) { |
394 | 408 | this.shareDetailsData = eventData |
395 | 409 | } |
| 410 | +
|
396 | 411 | this.showSharingDetailsView = !this.showSharingDetailsView |
| 412 | +
|
| 413 | + if (!this.showSharingDetailsView) { |
| 414 | + this.$nextTick(() => { // Wait for next tick as the element must be visible to be focused |
| 415 | + this.returnFocusElement?.focus() |
| 416 | + this.returnFocusElement = null |
| 417 | + }) |
| 418 | + } |
397 | 419 | }, |
398 | 420 | }, |
399 | 421 | } |
|
0 commit comments