Allow custom/new value
Hi, is it possible to allow the user to keep his search-phrase as a new value, if it is not available yet? thanks
You mean in search input, you press Enter, the current search text is added as a new option?
That or that the text is kept for further processing upon pressing the save button
lg Tilli
From: York Yao [email protected] Sent: Monday, December 14, 2020 8:18:04 AM To: plantain-00/select2-component [email protected] Cc: Tilfried Weissenberger [email protected]; Author [email protected] Subject: Re: [plantain-00/select2-component] Allow custom/new value (#42)
You mean in search input, you press Enter, the current search text is added as a new option?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/plantain-00/select2-component/issues/42#issuecomment-744228335, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABKK55V3AZAYGRKCZDXWI73SUW32ZANCNFSM4UZTWZDA.
You can try to listen search event and store search text, when you click you save button, just add the search text as a new option.
thanks! how can I have it stay in the textbox?
You can try to enable keepSearchText property.
keepSearchText will not do the job. If I intercept keydown and check for ev.code === "Enter" and add a new item and set the value etc. it works, but then if a user selects an existing item it won't. So I also need to listen to the update event. But then right after the keydown event does it's job, a "random" list item is being chosen and the update event is fired, overwriting the manual selection