#I am facing an issue while creating custom ref with clear input.
const api = useRef( [ ] );
api.current =fields.map((_, i) =>api.current[ i ] ?? createRef( ) );
case:
1.I have created a ref inside loop in ReactTags
exp:
here [index] is the Index value of mappping statement
I have created a button to clear this input
<Button onClick={ ( )=>clear( index ) }>
clear Input
Whenever i will try to clear input it's working.
this is my clearInput function:
const clear = ( i ) => {
api.current[i].current.input.focus( )
} ;
It somewhat irks me that addition + delete are combined, rather then addition + deletion, or add + delete. Perhaps now is a good time to unify the naming scheme.
Because the Input component is providing value attribute, the default HTML behavior of an <input type="reset"> does not clear the <input type="text">, since HTML input does not reset when a value attr is provided or set via setAttribute.
We are able to reset the selected prop but we cannot reset the input value attr as there is no prop to do so.
I can see a few ways here:
Change Input.tsx to not use value as a prop, but rather a useEffect that sets the input value imperatively. This allows the standard HTML type="reset" to clear it
Add a input prop to <ReactTags> that is passed to Input.tsx's value for a fully controlled input
The text input width accurately matches the text content it contains. The hidden "sizer" element accurately mimics the font of the input.
Current behaviour
In Safari the text input may have a smaller width applied which crops the text content. The hidden "sizer" element has the wrong font applied.
Steps to Reproduce
Steps to reproduce the problem:
Load the demo in Safari
Refresh until the bug is seen
Example and screenshots
With the hidden sizer element made visible, the font face and size is clearly wrong:
Additional context
Whilst debugging this issue the CSSStyleDeclaration generated by the input always reports the correct font face and size, even when a breakpoint is applied at the moment the incorrect value is retrieved. The stylesheet is loaded synchronously and script deferred (i.e. waits for stylesheets) so this appears to be a Safari bug.
This issue does not affect the v6 version of this component, nor affects the react-input-autosize component.
One difference I noticed compared to the old version is that the example has return true in the onAddition/onDelete handlers but it does not seem to be mentioned in the individual props’ docs. What is the purpose of the return value?
I'm aware this may be out of scope for your v7 roadmap, but I wanted to share it here.
This is something that Radix/HeadlessUI use and I feel like is more flexible, especially when it comes to layout. The general pattern is to provide a Root that contains the context, and the individual pieces like Input and TagList as pieces that the developer can place in a DOM structure they want, and access the context when wrapped in Root.
This has the added benefit of reducing the number of top-level props — by exporting the lower level components themselves, a developer can take advantage of the native React component props, such as all the event handlers, className, etc, which can cut down on the top-level props like classNames, onInput, isDisabled, placeholderText
Note that you can do this in addition to maintaining a "Default plug-and-play assembly" component that folks who want to just quickly use it can, but offer additional flexibility to reduce prop surface/maintenance as use cases grow.
most @ mention/tag/typeahead UX on the web, auto highlights the first matching item without needing to hit arrow-down to select it. is there a way to have this behavior?
Add an arbitrary width to the page container to make it horizontally scrollable. <main class="container"> -> <main class="container" style="width:4000px">
From the demo autocomplete component included in the page, try selecting an option
The suggestions dropdown appears when the second character is input, and stays displayed as long as 2 or more characters remain.
As soon as the input has 1 or less characters, the suggestions dropdown is collapsed.
Current behaviour
I haven't debugged any further than using the console.logs above, but the onShouldExpand callback is always invoked onInput, but with the previous value. For example, if I have just written foo, it gets called with fo.
Regarding onShouldCollapse, it never gets called onInput, but instead, it appears to be called onChange, so it only applies when the input looses focus (for example).
Steps to Reproduce
Using the code snippet above, you should be able to see the console.logs as described in previous point.
Example and screenshots
You can see it here in action on this recording (ignore the UI, I'm migrating from v6 and haven't tackled that yet).
Is there any way to disable the listbox when the user wants to remove the tags? Whenever a user (lets say its me) want to remove a particular tag the listbox automatically appears.
Hey, Is there any option to clear all the suggestions from the input of react tag and clear input field?
Case: I have a delete all button, I want to delete all suggestions on click that button.
Case: How to clear the input field on click custom clear button.
Hi, is this version supposed to achieve feature parity with the old extension? At the moment, it looks like it is much less customizable, while the old extension was almost perfect.
For example, for selfoss, I used the following with the old extension in the introducing PR:
<ReactTagsref={reactTags}tags={source.tags}inputAttributes={{id: `tags-${sourceId}`,// For associating it with a labelaccessKey: 'g',// For quick jump
onPaste,// I want to add a reasonable event handler but did not get to it yet.}}suggestions={tagSuggestions}// I abuse prefix field to add colour to each suggested tagonDelete={tagsOnDelete}onAddition={tagsOnAddition}allowNew={true}addOnBlur={true}minQueryLength={1}// Looks like the beta uses 0 now, which works for me.placeholderText={_('source_tags_placeholder')}removeButtonText={_('source_tag_remove_button_label')}newTagText={_('source_tags_create_new').replace('{0}','%value%')}// This will be great.classNames={reactTagsClassNames}delimiters={['Enter','Tab',',']}// Comma is much more convenient when typing on keyboardtagComponent={tagComponent}// Also used to add colour to tags/>
console.error
Error: Uncaught [TypeError: _a.scrollIntoView is not a function]
If I add skipClick: true like I see in your tests, the input doesn't go into the tagsField because another field is selected.
Trying to click the field first
await userEvent.click(tagsField);
I get the same error
The code works fine in the browser, it's just failing in the unit test. Any ideas?
Can you please let me know, how can i add own custom ui component as prop in V7 beta.
As currently the behaviour is , on click tag anywhere it is deleted. As I want to delete tag, only click via delete icon.
I'm not reporting this as a bug, even though for me it's a bit counter-intuitive behavior, because I see it being used consciously in the countries example.
Currently, when the same tag is added twice, it results in the tag getting actually removed. I guess this is because of the Api.select() method nature, which actually toggles tags.
duplicated-tags.webm
When using this library's v6, tags where actually passed twice to the onAddition callback, and it was easy to ignore duplicates by using a Set.
Now, if you actually want to ignore duplicates, instead of getting them removed, there's no easy workaround unless several event handlers are overwritten.
Because of this, it would be great to support an option disabling the removal on duplicated tags.
Describe alternatives you've considered
I have tried working around this via custom event handlers + API ref, but nothing seems to allow covering all ways to add tags (different keys, clicking on suggestions, selecting suggestions via keyboard, etc).
Currently Tag is expected to have the keys value and label. I'd love to have Typescript recognize additional metadata that I supply with it, e.g. having the suggestions prop be typed as <T extends Tag>?
Material UI renders its dropdown's listbox somewhere else in the page using a portal. This makes it possible to use the dropdown inside dialogs with it being able to overflow the dialog.
Example:
Currently in react-tag-autocomplete, this isn't possible, so if you use the component inside a dialog, it doesn't overflow properly.
In our application, the dropdown doesn't go over the dialog's footer, because the dialog's body has overflow: auto.
Using a portal to render the dropdown near the root element should allow this behavior.
When I run npm run build in the example project, I get:
The path "react-tag-autocomplete" is imported in app/lib/CountrySelector.tsx but "react-tag-autocomplete" was not found in your node_modules. Did you forget to install it?
When I run npm run dev, the ReactTags example does not load, and I get this error message displayed in the browser:
Error
Process exited with 1
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'react-tag-autocomplete'
Require stack:
- /Users/lpsinger/src/my-remix-app/server/index.js
- /Users/lpsinger/src/my-remix-app/server/[eval]
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/Users/lpsinger/src/my-remix-app/app/lib/CountrySelector.tsx:3:27)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
@i-like-robots
In current v7 beta I'm not able to select the option in the listbox by clicking on it or by using up/down key on keyboard and hit enter to add it to the list. It always sets the first item in the suggestions. Even API listobox.activeOption shows same first option selected when clicking on it.
Also, "selected" prop with selected state array removes previously added tags when I try to add another one