Skip to content

Commit

Permalink
feat(a11y): add option to disable tappable toots
Browse files Browse the repository at this point in the history
fixes #163. also fixed the issue where selecting text would cause the toot to be tapped
  • Loading branch information
nolanlawson committed Dec 3, 2018
1 parent ee3dfd8 commit b550e6e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 3 additions & 2 deletions routes/_components/status/Status.html
Expand Up @@ -122,7 +122,8 @@
export default {
oncreate () {
let { delegateKey, isStatusInOwnThread, showContent } = this.get()
if (!isStatusInOwnThread) {
let { disableTapOnStatus } = this.store.get()
if (!isStatusInOwnThread && !disableTapOnStatus) {
// the whole <article> is clickable in this case
registerClickDelegate(this, delegateKey, (e) => this.onClickOrKeydown(e))
}
Expand Down Expand Up @@ -268,4 +269,4 @@
})
}
}
</script>
</script>
7 changes: 6 additions & 1 deletion routes/_pages/settings/general.html
Expand Up @@ -32,6 +32,11 @@ <h2>Accessibility</h2>
bind:checked="$reduceMotion" on:change="onChange(event)">
<label for="choice-reduce-motion">Reduce motion in UI animations</label>
</div>
<div class="setting-group">
<input type="checkbox" id="choice-disable-tap-on-status"
bind:checked="$disableTapOnStatus" on:change="onChange(event)">
<label for="choice-disable-tap-on-status">Disable tappable area on entire toot</label>
</div>
<div class="setting-group">
<input type="checkbox" id="choice-omit-emoji-in-display-names"
bind:checked="$omitEmojiInDisplayNames" on:change="onChange(event)">
Expand Down Expand Up @@ -91,4 +96,4 @@ <h2>{themeTitle}</h2>
)
}
}
</script>
</script>
1 change: 1 addition & 0 deletions routes/_store/store.js
Expand Up @@ -12,6 +12,7 @@ const persistedState = {
currentRegisteredInstance: undefined,
disableCustomScrollbars: false,
disableLongAriaLabels: false,
disableTapOnStatus: false,
instanceNameInSearch: '',
instanceThemes: {},
loggedInInstances: {},
Expand Down
7 changes: 7 additions & 0 deletions routes/_utils/delegate.js
Expand Up @@ -14,6 +14,13 @@ function onEvent (e) {
// we're not interested in any non-click or non-Enter events
return
}
if (type === 'click') {
let selection = window.getSelection()
let selectionStr = selection && selection.toString()
if (selectionStr && selection.toString().length && target.contains(selection.anchorNode)) {
return // ignore if the user is selecting text inside the clickable area
}
}
mark('delegate onEvent')
let key
let element = target
Expand Down

0 comments on commit b550e6e

Please sign in to comment.