Skip to content

Commit 2b896a7

Browse files
authored
[bugfix] Restore scroll-to-setting in SettingDialog (#8833)
## Summary Restores the scroll-to-setting and highlight animation that was lost during the BaseModalLayout migration in #8270. Originally implemented in #8761. ## Changes - **What**: Re-added scroll-into-view + pulse highlight logic and CSS animation to `SettingDialog.vue`, ported from the deleted `SettingDialogContent.vue` Fixes #3437 ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8833-bugfix-Restore-scroll-to-setting-in-SettingDialog-3056d73d36508161abeee047a40dc1e5) by [Unito](https://www.unito.io)
1 parent 96b9e88 commit 2b896a7

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

src/platform/settings/components/SettingDialog.vue

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
</template>
7070

7171
<script setup lang="ts">
72-
import { computed, nextTick, provide, ref, watch } from 'vue'
72+
import { computed, nextTick, onBeforeUnmount, provide, ref, watch } from 'vue'
7373
7474
import SearchBox from '@/components/common/SearchBox.vue'
7575
import CurrentUserMessage from '@/components/dialog/content/setting/CurrentUserMessage.vue'
@@ -182,6 +182,31 @@ const searchResults = computed<ISettingGroup[]>(() => {
182182
return getSearchResults(category)
183183
})
184184
185+
// Scroll to and highlight the target setting once the correct category renders.
186+
if (scrollToSettingId) {
187+
const stopScrollWatch = watch(
188+
activeCategoryKey,
189+
() => {
190+
void nextTick(() => {
191+
const el = document.querySelector(
192+
`[data-setting-id="${CSS.escape(scrollToSettingId)}"]`
193+
)
194+
if (!el) return
195+
stopScrollWatch()
196+
el.scrollIntoView({ behavior: 'smooth', block: 'center' })
197+
el.classList.add('setting-highlight')
198+
el.addEventListener(
199+
'animationend',
200+
() => el.classList.remove('setting-highlight'),
201+
{ once: true }
202+
)
203+
})
204+
},
205+
{ immediate: true }
206+
)
207+
onBeforeUnmount(stopScrollWatch)
208+
}
209+
185210
watch(activeCategoryKey, (newKey, oldKey) => {
186211
if (!newKey && !inSearch.value) {
187212
activeCategoryKey.value = oldKey
@@ -198,3 +223,25 @@ watch(activeCategoryKey, (newKey, oldKey) => {
198223
}
199224
})
200225
</script>
226+
227+
<style>
228+
@media (prefers-reduced-motion: no-preference) {
229+
.setting-highlight {
230+
animation: setting-highlight-pulse 1.5s ease-in-out;
231+
}
232+
}
233+
234+
@keyframes setting-highlight-pulse {
235+
0%,
236+
100% {
237+
background-color: transparent;
238+
}
239+
30% {
240+
background-color: color-mix(
241+
in srgb,
242+
var(--p-primary-color) 15%,
243+
transparent
244+
);
245+
}
246+
}
247+
</style>

0 commit comments

Comments
 (0)