Skip to content

Commit

Permalink
Merge pull request #5902 from nextcloud-libraries/backport/5896/next
Browse files Browse the repository at this point in the history
[next] feat(NcPasswordField): add as-text prop to remove autocomplete
  • Loading branch information
ShGKme committed Aug 3, 2024
2 parents ddabade + 06e29c9 commit 25967f0
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/components/NcPasswordField/NcPasswordField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ General purpose password field component.
<NcPasswordField v-model="text5"
:disabled="true"
label="Disabled" />

<NcPasswordField :value.sync="text6"
label="Secret token"
as-text />
</div>
</template>
<script>
Expand All @@ -57,6 +61,7 @@ export default {
text3: 'hunter',
text4: '',
text5: '',
text6: 'secret-token',
}
},
Expand Down Expand Up @@ -91,7 +96,7 @@ export default {
<template>
<NcInputField v-bind="propsToForward"
ref="inputField"
:type="isPasswordHidden ? 'password' : 'text'"
:type="isPasswordHidden && !asText ? 'password' : 'text'"
:trailing-button-label="trailingButtonLabelPassword"
:helper-text="computedHelperText"
:error="computedError"
Expand Down Expand Up @@ -204,6 +209,18 @@ export default {
type: Number,
default: null,
},
/**
* Render as input[type=text] that looks like password field.
* Allows to avoid unwanted password-specific browser behavior,
* such as save or generate password prompt.
* Useful for secret token fields.
* Note: autocomplete="off" is ignored by browsers.
*/
asText: {
type: Boolean,
default: false,
},
},
emits: [
Expand Down Expand Up @@ -324,3 +341,11 @@ export default {
},
}
</script>
<style lang="scss" scoped>
:deep(.password-field__input--secure-text) {
// Emulate password field look
// This is not a part of the standard but well supported
-webkit-text-security: disc;
}
</style>

0 comments on commit 25967f0

Please sign in to comment.