Skip to content

Commit 0164064

Browse files
authored
fix: add ignore attributes for password managers to input fields (#2466)
1 parent f5bb3ed commit 0164064

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

app/components/CommandPalette.client.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ useEventListener(document, 'keydown', handleGlobalKeydown)
324324
type="text"
325325
:placeholder="viewMeta.placeholder"
326326
no-correct
327+
no-password-manager
327328
size="lg"
328329
class="w-full"
329330
:aria-describedby="inputDescribedBy"

app/components/Input/Base.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { noCorrect } from '~/utils/input'
2+
import { noCorrect, noPasswordManager } from '~/utils/input'
33
44
const model = defineModel<string>({ default: '' })
55
@@ -16,6 +16,12 @@ const props = withDefaults(
1616
noCorrect?: boolean
1717
/** Keyboard shortcut hint */
1818
ariaKeyshortcuts?: string
19+
/**
20+
* Prevents most common password managers from recognizing the input as a password field.
21+
* Note: This is not a standard HTML attribute but vendor-specific data-* attributes.
22+
* @default false
23+
*/
24+
noPasswordManager?: boolean
1925
}>(),
2026
{
2127
size: 'md',
@@ -36,13 +42,18 @@ defineExpose({
3642
focus: () => el.value?.focus(),
3743
blur: () => el.value?.blur(),
3844
})
45+
46+
const inputAttrs = computed(() => ({
47+
...(props.noCorrect ? noCorrect : {}),
48+
...(props.noPasswordManager ? noPasswordManager : {}),
49+
}))
3950
</script>
4051

4152
<template>
4253
<input
4354
ref="el"
4455
v-model="model"
45-
v-bind="props.noCorrect ? noCorrect : undefined"
56+
v-bind="inputAttrs"
4657
@focus="emit('focus', $event)"
4758
@blur="emit('blur', $event)"
4859
class="appearance-none bg-bg-subtle border border-border font-mono text-fg placeholder:text-fg-subtle transition-[border-color,outline-color] duration-300 hover:border-fg-subtle outline-2 outline-transparent outline-offset-2 focus:border-accent focus-visible:outline-accent/70 disabled:(opacity-50 cursor-not-allowed)"

app/utils/input.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,15 @@ export function isKeyWithoutModifiers(event: KeyboardEvent, key: string): boolea
2828
}
2929

3030
export const DATE_INPUT_MAX = '9999-12-31'
31+
32+
/** Attributes to prevent password managers from recognizing an input as a password field. */
33+
export const noPasswordManager = {
34+
/* ProtonPass, https://stackoverflow.com/a/51272839 */
35+
['data-protonpass-ignore']: 'true',
36+
/* LastPass, https://stackoverflow.com/a/51272839 */
37+
['data-lpignore']: 'true',
38+
/* 1Password, https://stackoverflow.com/a/51272839 */
39+
['data-1p-ignore']: 'true',
40+
/* Bitwarden, https://stackoverflow.com/questions/41945535/html-disable-password-manager#comment139327111_51272839 */
41+
['data-bwignore']: 'true',
42+
} as const

0 commit comments

Comments
 (0)