Skip to content

Commit

Permalink
fixes #854 - Support "disabled" input attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Yair Even Or authored and Yair Even Or committed Jul 3, 2021
1 parent 2f9b41c commit 79408ea
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
6 changes: 4 additions & 2 deletions dist/react.tagify.js
Expand Up @@ -89,6 +89,7 @@ const TagifyWrapper = ({
onDropdownNoMatch = noop,
onDropdownUpdated = noop,
readOnly,
disabled,
children,
settings = {},
InputMode = "input",
Expand All @@ -112,6 +113,7 @@ const TagifyWrapper = ({
defaultValue: children || typeof _value == 'string' ? _value : JSON.stringify(_value),
className,
readOnly,
disabled,
autoFocus,
placeholder
}), []);
Expand Down Expand Up @@ -166,9 +168,9 @@ const TagifyWrapper = ({
}, [loading]);
(0, _react.useEffect)(() => {
if (mountedRef.current) {
tagify.current.setReadonly(readOnly);
tagify.current.setReadonly(readOnly || disabled);
}
}, [readOnly]);
}, [readOnly, disabled]);
(0, _react.useEffect)(() => {
const t = tagify.current;

Expand Down
2 changes: 1 addition & 1 deletion dist/tagify.min.js
Expand Up @@ -1819,7 +1819,7 @@

var _s = this.settings = extend({}, DEFAULTS, settings);

_s.readonly = input.hasAttribute('readonly'); // if "readonly" do not include an "input" element inside the Tags component
_s.readonly = input.hasAttribute('readonly') || input.hasAttribute('disabled'); // if "readonly" do not include an "input" element inside the Tags component

_s.placeholder = input.getAttribute('placeholder') || _s.placeholder || "";
_s.required = input.hasAttribute('required');
Expand Down
6 changes: 4 additions & 2 deletions src/react.tagify.js
Expand Up @@ -49,6 +49,7 @@ const TagifyWrapper = ({
onDropdownNoMatch = noop,
onDropdownUpdated = noop,
readOnly,
disabled,
children,
settings = {},
InputMode = "input",
Expand All @@ -71,6 +72,7 @@ const TagifyWrapper = ({
defaultValue: children || typeof _value == 'string' ? _value : JSON.stringify(_value),
className,
readOnly,
disabled,
autoFocus,
placeholder,
}), [])
Expand Down Expand Up @@ -164,9 +166,9 @@ const TagifyWrapper = ({

useEffect(() => {
if (mountedRef.current) {
tagify.current.setReadonly(readOnly)
tagify.current.setReadonly(readOnly || disabled)
}
}, [readOnly])
}, [readOnly, disabled])

useEffect(() => {
const t = tagify.current
Expand Down
2 changes: 1 addition & 1 deletion src/tagify.js
Expand Up @@ -97,7 +97,7 @@ Tagify.prototype = {

var _s = this.settings = extend({}, DEFAULTS, settings)

_s.readonly = input.hasAttribute('readonly') // if "readonly" do not include an "input" element inside the Tags component
_s.readonly = input.hasAttribute('readonly') || input.hasAttribute('disabled') // if "readonly" do not include an "input" element inside the Tags component
_s.placeholder = input.getAttribute('placeholder') || _s.placeholder || ""
_s.required = input.hasAttribute('required')

Expand Down

0 comments on commit 79408ea

Please sign in to comment.