Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R20-1730] Fixed icon not changing when exiting fullscreen map via keyboard #993

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions packages/ripple-ui-maps/src/components/map/RplMap.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { RplIcon } from '@dpc-sdp/ripple-ui-core/vue'
import type { IRplMapFeature } from './../../types'
import { onMounted, onUnmounted, ref, inject, computed, watch } from 'vue'
import { useFullscreen } from '@vueuse/core'
import { Map } from 'ol'
import { Point } from 'ol/geom'
import Icon from 'ol/style/Icon'
Expand Down Expand Up @@ -78,13 +79,10 @@
}
})

const {
onHomeClick,
onZoomInClick,
onZoomOutClick,
onFullScreenClick,
isFullScreenRef
} = useMapControls(mapRef, center, props.initialZoom)
const { isFullscreen } = useFullscreen()

const { onHomeClick, onZoomInClick, onZoomOutClick, onFullScreenClick } =
useMapControls(mapRef, center, props.initialZoom)

const mapFeatures = computed(() => {
if (Array.isArray(props.features)) {
Expand Down Expand Up @@ -213,7 +211,7 @@
<div
v-if="noresults && !hideNoResults"
class="rpl-map__noresults"
ref="noResultsRef"

Check warning on line 214 in packages/ripple-ui-maps/src/components/map/RplMap.vue

View workflow job for this annotation

GitHub Actions / Test

Attribute "ref" should go before "class"
>
<button
title="dismiss no results message"
Expand Down Expand Up @@ -295,7 +293,7 @@
</slot>
<div class="rpl-map__control rpl-map__control-fullscreen">
<button title="View map fullscreen" @click="onFullScreenClick">
<RplIcon v-if="isFullScreenRef" name="icon-cancel"></RplIcon>
<RplIcon v-if="isFullscreen" name="icon-cancel"></RplIcon>
<RplIcon v-else name="icon-enlarge" size="m"></RplIcon>
</button>
</div>
Expand Down
10 changes: 3 additions & 7 deletions packages/ripple-ui-maps/src/composables/useMapControls.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { easeOut } from 'ol/easing'
import { centerMap } from './../components/map/utils.ts'
import { ref } from 'vue'
export default (mapRef, center, initialZoom) => {
const isFullScreenRef = ref(false)

export default (mapRef, center, initialZoom) => {
/**
* @param {number} delta Zoom delta.
* @private
Expand Down Expand Up @@ -98,17 +96,16 @@ export default (mapRef, center, initialZoom) => {
if (!isFullScreenSupported(doc)) {
return
}

if (isFullScreen(doc)) {
exitFullScreen(doc)
isFullScreenRef.value = false
} else {
const element = map.getTargetElement()
if (withKeys) {
requestFullScreenWithKeys(element)
} else {
requestFullScreen(element)
}
isFullScreenRef.value = true
}
}

Expand All @@ -129,7 +126,6 @@ export default (mapRef, center, initialZoom) => {
onHomeClick,
onZoomInClick,
onZoomOutClick,
onFullScreenClick,
isFullScreenRef
onFullScreenClick
}
}
Loading