diff --git a/.changeset/orange-suits-notice.md b/.changeset/orange-suits-notice.md new file mode 100644 index 00000000..f3e8703f --- /dev/null +++ b/.changeset/orange-suits-notice.md @@ -0,0 +1,5 @@ +--- +"react-mentions": minor +--- + +Added support to disable suggestion selection diff --git a/README.md b/README.md index 6d2a7f2b..e15cbbf1 100755 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Each data source is configured using a `Mention` component, which has the follow | Prop name | Type | Default value | Description | | ---------------- | ------------------------------------------------------------ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | | trigger | regexp or string | `'@'` | Defines the char sequence upon which to trigger querying the data source | -| data | array or function (search, callback) | `null` | An array of the mentionable data entries (objects with `id` & `display` keys, or a filtering function that returns an array based on a query parameter | +| data | array or function (search, callback) | `null` | An array of the mentionable data entries (objects with `id`, `display` & optional `disabled` keys), or a filtering function that returns an array based on a query parameter | | renderSuggestion | function (entry, search, highlightedDisplay, index, focused) | `null` | Allows customizing how mention suggestions are rendered (optional) | | markup | string | `'@[__display__](__id__)'` | A template string for the markup to use for mentions | | displayTransform | function (id, display) | returns `display` | Accepts a function for customizing the string that is displayed for a mention | diff --git a/demo/src/examples/Examples.js b/demo/src/examples/Examples.js index 1e1e7e82..dd5d69eb 100644 --- a/demo/src/examples/Examples.js +++ b/demo/src/examples/Examples.js @@ -46,6 +46,7 @@ const users = [ { id: 'jesse', display: 'Jesse Pinkman', + disabled: true, }, { id: 'gus', diff --git a/demo/src/examples/defaultStyle.js b/demo/src/examples/defaultStyle.js index 1b264aa4..fd286b11 100644 --- a/demo/src/examples/defaultStyle.js +++ b/demo/src/examples/defaultStyle.js @@ -46,6 +46,10 @@ export default { '&focused': { backgroundColor: '#cee4e5', }, + '&disabled': { + color: 'rgba(0,0,0,0.3)', + cursor: 'default', + }, }, }, } diff --git a/src/LoadingIndicator.js b/src/LoadingIndicator.js index ed9a42aa..c8278c47 100644 --- a/src/LoadingIndicator.js +++ b/src/LoadingIndicator.js @@ -5,7 +5,7 @@ function LoadingIndicator({ style, className, classNames }) { const styles = useStyles(defaultstyle, { style, className, classNames }) const spinnerStyles = styles('spinner') return ( -