Skip to content

Commit

Permalink
add a disabled prop to text field
Browse files Browse the repository at this point in the history
  • Loading branch information
ipula committed Feb 6, 2025
1 parent 5ef5ae4 commit 256ffc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/components/Form/fields/FieldText.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ export const Large = {
},
};

export const Disabled = {
args: {
...FieldBaseMock,
...FieldTextGivenNameMock,
isRequired: false,
disabled: true,
},
};

export const WithPrefix = {
args: {
...FieldBaseMock,
Expand Down
7 changes: 6 additions & 1 deletion src/components/Form/fields/FieldText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ export default {
},
/** An optional prefix to show before the user's input. For example, a prefix of `http://publisher.com/` is used for the journal `path` field. */
prefix: String,
/** A boolean value make text field disable */
disabled: {
type: Boolean,
default: false,
},
},
data() {
return {
Expand Down Expand Up @@ -211,7 +216,7 @@ export default {
});
// Set the field to disabled if optIntoEdit is passed
if (this.optIntoEdit) {
if (this.optIntoEdit || this.disabled) {
this.isDisabled = true;
}
},
Expand Down

0 comments on commit 256ffc6

Please sign in to comment.