Skip to content

Fix/layer options tabbing #315

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

Merged
merged 5 commits into from
Apr 14, 2025
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
1 change: 1 addition & 0 deletions packages/plugins/LayerChooser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Feature: Change configuration of `layer.type` to be set to `background` or any other String. All layers that have their `type` not set to `background` are considered "overlays". For the type `mask` locales are already implemented. For any additional type, these have to be added separately.
- Feature: Add new exported type `DisabledLayers` describing an object structure mapping layerIds to whether the respective layer is disabled or not.
- Fix: Layer options layer names are now translated if they're locale keys.
- Fix: Resolve an issue of loosing visible focus when using the keyboard to open or close the layer options menu.

## 2.1.0

Expand Down
11 changes: 10 additions & 1 deletion packages/plugins/LayerChooser/src/components/LayerWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
<div class="polar-layer-chooser-option-line" v-on="disabled && on">
<slot></slot>
<v-btn
:id="`polar-layer-chooser-options-${layerId}-button`"
class="ml-1"
:class="!hasOptions && 'polar-layer-chooser-option-invisible'"
:aria-label="$t('plugins.layerChooser.layerOptions')"
icon
small
@click="setOpenedOptions(layerId)"
@click="updateOpenedOptions(layerId)"
>
<v-icon small>{{ icon }}</v-icon>
</v-btn>
Expand Down Expand Up @@ -55,6 +56,14 @@ export default Vue.extend({
},
methods: {
...mapMutations('plugin/layerChooser', ['setOpenedOptions']),
updateOpenedOptions(layerId: string) {
this.setOpenedOptions(layerId)
this.$nextTick(() =>
(document.querySelector('[data-app]') as ShadowRoot)
.getElementById('polar-layer-chooser-options-back-button')
?.focus()
)
},
},
})
</script>
Expand Down
20 changes: 17 additions & 3 deletions packages/plugins/LayerChooser/src/components/Options.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
<v-card class="layer-chooser-options">
<v-card-actions>
<v-btn
id="polar-layer-chooser-options-back-button"
icon
small
:aria-label="$t('plugins.layerChooser.returnToLayers')"
@click="setOpenedOptions(null)"
@click="closeOptions"
>
<v-icon small>fa-chevron-left</v-icon>
</v-btn>
Expand Down Expand Up @@ -56,11 +57,11 @@ import { mapGetters, mapMutations, mapActions } from 'vuex'
export default Vue.extend({
name: 'LayerChooserOptions',
computed: {
...mapGetters(['clientWidth']),
...mapGetters('plugin/layerChooser', [
'activeLayerIds',
'openedOptions',
'openedOptionsService',
'openedOptionsServiceLayers',
'activeLayerIds',
]),
activeLayers: {
get() {
Expand All @@ -74,6 +75,19 @@ export default Vue.extend({
methods: {
...mapMutations('plugin/layerChooser', ['setOpenedOptions']),
...mapActions('plugin/layerChooser', ['toggleOpenedOptionsServiceLayer']),
closeOptions() {
const previousOptions = this.openedOptions
this.setOpenedOptions(null)
this.$nextTick(() => {
const button = (
document.querySelector('[data-app]') as ShadowRoot
).getElementById(
`polar-layer-chooser-options-${previousOptions}-button`
)
// Sadly needed as the button is not focused otherwise.
setTimeout(() => button?.focus(), 0)
})
},
},
})
</script>
Expand Down