Skip to content

Instantly share code, notes, and snippets.

View ryanw3b3r's full-sized avatar
💪
Having a very productive day

Ryan W ryanw3b3r

💪
Having a very productive day
View GitHub Profile
@ryanw3b3r
ryanw3b3r / ModalFocusTrap.vue
Created August 17, 2023 13:04
Trap TAB and Shift+TAB in modal or any other element. Just wrap it in this component.
<script lang="ts" setup>
import { type Ref, onMounted, ref } from 'vue'
const selectors = 'a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled])'
const wrapper: Ref<HTMLElement | undefined> = ref()
const focusableEls: Ref<Array<HTMLElement>> = ref([])
const firstFocusableEl: Ref<HTMLElement | undefined> = ref()
const lastFocusableEl: Ref<HTMLElement | undefined> = ref()
function handleBackwardMove(event: KeyboardEvent): void {
@ryanw3b3r
ryanw3b3r / settings.json
Last active November 17, 2022 16:11
VS Code perfect setup
{
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"[php]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true
},
"breadcrumbs.enabled": false,