Compare commits

...

5 Commits

Author SHA1 Message Date
Damian Głowala
7f97694c5b
Merge df5038a272 into edc299a043 2024-11-20 06:35:52 -05:00
renovate[bot]
edc299a043
chore(deps): update all non-major dependencies (main) (#29995)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-20 06:35:43 -05:00
renovate[bot]
ad3ab4d310
chore(deps): update all non-major dependencies (main) (#29986)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2024-11-19 23:36:17 -05:00
Damian Glowala
df5038a272 chore: simplify conditional statements 2024-09-14 10:36:49 +02:00
Damian Glowala
d8d89b9dee fix(nuxt): wait for page:finish hook in CSR before scrolling to hash on page enter 2024-09-14 10:31:16 +02:00
4 changed files with 16 additions and 13 deletions

View File

@ -248,7 +248,7 @@ jobs:
TEST_PAYLOAD: ${{ matrix.payload }} TEST_PAYLOAD: ${{ matrix.payload }}
SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || matrix.payload == 'js' || runner.os == 'Windows' }} SKIP_BUNDLE_SIZE: ${{ github.event_name != 'push' || matrix.env == 'dev' || matrix.builder == 'webpack' || matrix.context == 'default' || matrix.payload == 'js' || runner.os == 'Windows' }}
- uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2 - uses: codecov/codecov-action@985343d70564a82044c1b7fcb84c2fa05405c1a2 # v5.0.4
if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on' if: github.event_name != 'push' && matrix.env == 'built' && matrix.builder == 'vite' && matrix.context == 'default' && matrix.os == 'ubuntu-latest' && matrix.manifest == 'manifest-on'
with: with:
token: ${{ secrets.CODECOV_TOKEN }} token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -91,7 +91,7 @@
"devalue": "5.1.1", "devalue": "5.1.1",
"eslint": "9.15.0", "eslint": "9.15.0",
"eslint-plugin-no-only-tests": "3.3.0", "eslint-plugin-no-only-tests": "3.3.0",
"eslint-plugin-perfectionist": "4.0.2", "eslint-plugin-perfectionist": "4.0.3",
"eslint-typegen": "0.3.2", "eslint-typegen": "0.3.2",
"h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e", "h3": "npm:h3-nightly@2.0.0-1718872656.6765a6e",
"happy-dom": "15.11.6", "happy-dom": "15.11.6",
@ -118,7 +118,7 @@
"vue-router": "4.4.5", "vue-router": "4.4.5",
"vue-tsc": "2.1.10" "vue-tsc": "2.1.10"
}, },
"packageManager": "pnpm@9.13.2", "packageManager": "pnpm@9.14.1",
"engines": { "engines": {
"node": "^16.10.0 || >=18.0.0" "node": "^16.10.0 || >=18.0.0"
}, },

View File

@ -28,13 +28,11 @@ export default <RouterConfig> {
} }
// Hash routes on the same page, no page hook is fired so resolve here // Hash routes on the same page, no page hook is fired so resolve here
if (to.path === from.path) { if (to.path === from.path && !to.hash) {
if (from.hash && !to.hash) { if (from.hash) {
return { left: 0, top: 0 } return { left: 0, top: 0 }
} }
if (to.hash) {
return { el: to.hash, top: _getHashElementScrollMarginTop(to.hash), behavior }
}
// The route isn't changing so keep current scroll position // The route isn't changing so keep current scroll position
return false return false
} }
@ -42,12 +40,15 @@ export default <RouterConfig> {
// Wait for `page:transition:finish` or `page:finish` depending on if transitions are enabled or not // Wait for `page:transition:finish` or `page:finish` depending on if transitions are enabled or not
const hasTransition = (route: RouteLocationNormalized) => !!(route.meta.pageTransition ?? defaultPageTransition) const hasTransition = (route: RouteLocationNormalized) => !!(route.meta.pageTransition ?? defaultPageTransition)
const hookToWait = (hasTransition(from) && hasTransition(to)) ? 'page:transition:finish' : 'page:finish' const hookToWait = (hasTransition(from) && hasTransition(to)) ? 'page:transition:finish' : 'page:finish'
return new Promise((resolve) => { return new Promise((resolve) => {
nuxtApp.hooks.hookOnce(hookToWait, async () => { nuxtApp.hooks.hookOnce(hookToWait, async () => {
await new Promise(resolve => setTimeout(resolve, 0)) await new Promise(resolve => setTimeout(resolve, 0))
if (to.hash) { if (to.hash) {
position = { el: to.hash, top: _getHashElementScrollMarginTop(to.hash), behavior } position = { el: to.hash, top: _getHashElementScrollMarginTop(to.hash), behavior }
} }
resolve(position) resolve(position)
}) })
}) })
@ -57,11 +58,13 @@ export default <RouterConfig> {
function _getHashElementScrollMarginTop (selector: string): number { function _getHashElementScrollMarginTop (selector: string): number {
try { try {
const elem = document.querySelector(selector) const elem = document.querySelector(selector)
if (elem) { if (elem) {
return (Number.parseFloat(getComputedStyle(elem).scrollMarginTop) || 0) + (Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop) || 0) return (Number.parseFloat(getComputedStyle(elem).scrollMarginTop) || 0) + (Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop) || 0)
} }
} catch { } catch {
// ignore any errors parsing scrollMarginTop // ignore any errors parsing scrollMarginTop
} }
return 0 return 0
} }

View File

@ -114,8 +114,8 @@ importers:
specifier: 3.3.0 specifier: 3.3.0
version: 3.3.0 version: 3.3.0
eslint-plugin-perfectionist: eslint-plugin-perfectionist:
specifier: 4.0.2 specifier: 4.0.3
version: 4.0.2(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3) version: 4.0.3(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)
eslint-typegen: eslint-typegen:
specifier: 0.3.2 specifier: 0.3.2
version: 0.3.2(eslint@9.15.0(jiti@2.4.0)) version: 0.3.2(eslint@9.15.0(jiti@2.4.0))
@ -4373,8 +4373,8 @@ packages:
resolution: {integrity: sha512-brcKcxGnISN2CcVhXJ/kEQlNa0MEfGRtwKtWA16SkqXHKitaKIMrfemJKLKX1YqDU5C/5JY3PvZXd5jEW04e0Q==} resolution: {integrity: sha512-brcKcxGnISN2CcVhXJ/kEQlNa0MEfGRtwKtWA16SkqXHKitaKIMrfemJKLKX1YqDU5C/5JY3PvZXd5jEW04e0Q==}
engines: {node: '>=5.0.0'} engines: {node: '>=5.0.0'}
eslint-plugin-perfectionist@4.0.2: eslint-plugin-perfectionist@4.0.3:
resolution: {integrity: sha512-zWdgyg2SdHqhp/P9d9vKwo5qD9is28xMAGzBslHqkZz5mVIikjyz1qvuJ4yS7Wrsf4KlbGorORefb4Kbe7Puzg==} resolution: {integrity: sha512-CyafnreF6boy4lf1XaF72U8NbkwrfjU/mOf1y6doaDMS9zGXhUU1DSk+ZPf/rVwCf1PL1m+rhHqFs+IcB8kDmA==}
engines: {node: ^18.0.0 || >=20.0.0} engines: {node: ^18.0.0 || >=20.0.0}
peerDependencies: peerDependencies:
eslint: '>=8.0.0' eslint: '>=8.0.0'
@ -11519,7 +11519,7 @@ snapshots:
eslint-plugin-no-only-tests@3.3.0: {} eslint-plugin-no-only-tests@3.3.0: {}
eslint-plugin-perfectionist@4.0.2(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3): eslint-plugin-perfectionist@4.0.3(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3):
dependencies: dependencies:
'@typescript-eslint/types': 8.15.0 '@typescript-eslint/types': 8.15.0
'@typescript-eslint/utils': 8.15.0(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3) '@typescript-eslint/utils': 8.15.0(eslint@9.15.0(jiti@2.4.0))(typescript@5.6.3)