How to Change state of Multiple values chips of React matrieal UI Autocomplete - reactjs

I want to implement a function by React Material UI Autocomplete.
This is the document I have checked: https://mui.com/material-ui/react-autocomplete/
The function I am trying to develop is that a user can select multiple values from the autocomplete list, which are displayed as chips just like the example in the document above.
The advanced part is, for example, a chip can be displayed in red color as default, and when a user clicks the chip, it can become blue color. That is, A User can control every chip's state by clicking on those chips to achieve toggling function.
For example, a user selects "Tea", "Baseball", and "Pencil" from the Multiple values autocomplete list, then "Tea", "Baseball" and "Pencil" are displayed red color initially. When the user clicks on the "Tea" chip, it can become blue color while "Baseball" and "Pencil" remain red. Next, when the user clicks on the "Tea" chip again, it can become back to red color again while "Baseball" and "Pencil" remain red. Moreover, I want to get every chips' current color state also.
I read the document for quite a long time, but still have no idea how to implement stateful multiple values autocomplete component.
Thanks for the help from all of you.

Managing colors in itself isn't complex. But the functionality you want regarding maintaining which chips are selected after user enters in drop down isn't provided by this component. What you want is a list to be populated based on the values user enters in the dropdown. They should show up as chips in red and only once user clicks on them they should be turned to blue (hence finally selected). If you will look closely at that component, this feature isn't there.
You need some other alternative or you would need to make a custom component. You can check this component and try for a custom implementation. https://mui.com/material-ui/react-chip/

Related

MUI Autocomplete filter view as user types

What I'm trying to achieve with MUI's React-Autocomplete is what would probably be a typical use case, yet, I can't find any example that illustrates what I'm trying to achieve. And the documentation is lacking IMO.
So, I have this autocomplete component with a list of options (listOfOptions).
As the user types, in the input box, I would like to auto filter the list of options that appear on the dashboard, below that autocomplete input.
Say, the listOfOptions is a list of countries. And the dashboard shows the list of countries with their associated flags.
The user starts to type "R". The autocomplete will obviously filter out countries that do not start with R. What I want is that the dashboard now also filters in countries starting with R. It should show : Russia, Romania, etc...
I have played, in vain, with all props (onInputChange, onChange, onChange inside of renderInput, etc...). Applying a filter to my listOfOptions, in whichever of these mentioned change handlers doesn't work. It filters but makes me lose the prompt after the first key.
Not sure how to do it. Any hint would be greatly appreciated.

CodenameOne set indexing of fields for virtual keyboard

Using CodenameOne,
I have a Form that the user needs to fill in. All of the components, however, are actually Containers that represent custom functionality. As an example, I would have a TextField alongside a Button on a Container, and I would use that Container as a "Component". This allows me to create more advanced functionality by combining existing Components.
A good example of where this is necessary is that of a custom date entry field existing out of 3 TextFields or a combination of TextFields and ComboBoxes.
I have a "Field" that has functionality for that of a Contact Component.
This all serves as a single "Unit" in order to allow the user to choose a contact or fill in their own. Buttons open Dialog popups, etc.
My problems comes with when the user uses the Android keyboard. Should this Contact Object be the second "Field" and the user presses the 'Next' button on the Android keyboard, the App does not know what field to give focus.
Furthermore, If one of the fields are a ComboBox or a Button and the user presses next to reach that Component, the keyboard doesn't close, and instead removes the 'Next' button, replacing it with a return button or an emoticon selector.
Below is an example situation:
The user would press on the first field, the Keyboard shows up, and when the user presses next, the keyboard's Next button dissapears, as the immediate next field happens to be a Button or ComboBox.
Is there a way to change the focusing index, or omit certain fields form ever gaining focus in this way? I tried making the entire thing a Component but that doesnt allow me to combine other Components. Even if it is possible to make the parent Container a Component, how would I solve this particular issue?
The default behavior is to use the "next focus down" for this functionality so just use setNextFocusDown(nextTextField) on each one of the components. Notice that a ComboBox won't work as expected although you might want to change that to an AutoCompleteTextField which would.

Codename One - TextField appearance

I have a GUI built app and am trying to emulate the TextFIeld look of the Yahoo Mail page, where the underline of the TextField turns to blue when pressed.
I changed the "pressed" and "selected" state of the TextField UIID, but it only changes when I press it, but it doesn't stay that way and it turns back to grey.
Question:
Is there some kind of "toggle" function in TextFields as in CheckBoxes, so the new state stays that way?
Only selected state is used in text field (not pressed) and it should remain blue. It seems this is an issue with Codename One possibly a recent regression due to recent changes to text editing.
I've filed an issue on that here.

Hide a currency Shield UI chart while showing Forex rates

I have a page with a couple of Shield UI Charts, showing different cross currencies forex rates. The type of the charts is line, in case that would make any difference. When I click on a chart’s legend and hide the series it works. However on the next refresh the chart’s data pops up again and the series I just turned off are on again. Is there a workaround this behavior?
One easy way I can think of is to add a checkbox in each of the charts containers let’s say an initially non checked checkbox element. Something like that:
<input type=checkbox id="Chart_A">Hide Chart</input>
Than, when the refresh function is called simply check whether the checkbox is on or off and show the chart accordingly.

Conditional Formatting based on layout view

Another question for you Filemaker Pro experts. The database I am developing starts with a Main layout with a number of buttons (e.g. insert new item, show all items, etc.). Each button is associated to a script, which takes the user to the relevant layout. In each of these layouts I show the buttons in a row, and highlight the current layout with inverse colour.
My problem is that some of the buttons lead to the same layout, viewed in different modes, and I don't know how to conditionally highlight the right button.
For instance, Insert new item and Show all items take to the same layout, however in the first case the script views the layout as a form and inserts a new record, while in the second I view as a list and show all records. The layout is the same, though, so I'd need to enact a conditional formatting based on something. How do I do that, and what should I check against?
Thanks in advance for any help.
Regards.
Presumably you are currently using the formula: Get (LayoutName) to decide on your conditional formula, why not try additionally using formulas: Get(WindowMode) and Get(LayoutViewState)?
You could conditionally format the button if (which sends user to MyLayout in browse mode):
Get(WindowMode)=0 and Get(LayoutName)="MyLayout"
Or (which sends user to MyLayout in form view):
Get(LayoutViewState)=0 and Get(LayoutName)="MyLayout"
.
Other functions which may help could be Get(FoundCount) and Get(TotalRecordCount). You can see the entire list of Get functions here.

Resources