Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: MDB Bootstrap Support

gllermaly free asked 6 years ago


Hello, 

Maybe Im not getting it but select still showing "value" instead of text in the option text place when using controlled options (options as state object)

Mi object looks like this :


options: [
{
checked:true,
disabled:false,
icon:null,
value:"A",
text:"Option A"
},
{
checked:false,
disabled:false,
icon:null,
text:"Option two",
value:"2"
},
{
checked:false,
disabled:false,
icon:null,
text:"Option three",
value:"3"
},
{
checked:false,
disabled:false,
icon:null,
text:"Option four",
value:"4"
}
]

Select must render like this , right?

<select>
<option value="1"> Option one </option>....

but is rendering like this 
<select>
<option value="1"> 1 </option>....
 
What I'm doing wrong? 
 
BTW: Now searchLabel is not being recognized
 
Warning: React does not recognize the `searchLabel` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `searchlabel` instead. If you accidentally passed it from a parent component, remove it from the DOM element.

gllermaly free answered 6 years ago


Restarted project, replaced code with yours and did npm install and now texts are showing, but I have this warning:

Warning: Failed prop type: Invalid prop `data[0]` of type `object` supplied to `t`, expected `string`.

and "search" is searching against values and not texts , please fix or tell me how to do it

Thanks 


gllermaly free commented 6 years ago

Warning dissapears when I remove the search prop


Jakub Mandra staff commented 6 years ago

Thanks for report.

This is an actual bug, because search data is wrongly attached. It works ok, but we have to deal with that error. Will inform about the work progress.

 

Best


gllermaly free commented 6 years ago

Thanks, I hope you are aware about "search" is searching against values and not texts , please fix or tell me how to do it


Jakub Mandra staff commented 6 years ago

Thank you, we are.

The fixes should be released in Monday, two weeks from now.


gllermaly free commented 6 years ago

Nice! , please dont forget about this!!


Jakub Mandra staff commented 6 years ago

Issue has been resolved and is waiting on dev branch for release. It will take place on Monday :)


gllermaly free answered 6 years ago


Hi, did npm update mdbreact and version shows 4.8.7. Not sure if I need aditional steps 

Thanks 


Jakub Mandra staff answered 6 years ago


Hi,

Have you updated mdbreact properly?
Material select actually should render like:

<ul class="select-dropdown ...">
  <li {some attributes}>
    <span data-mulitple="false" class="filtrable">Option A</span>

And values of options are in the inner state of the select component.

It's because it is not possible to attach those complicated material styles to native select component. 

Here is the full code snippet:

import React, { Component } from "react";
import { MDBSelect } from "mdbreact";

class SelectPage extends Component {
state = {
options: [
{
checked: true,
disabled: false,
icon: null,
value: "A",
text: "Option A"
},
{
checked: false,
disabled: false,
icon: null,
text: "Option two",
value: "2"
},
{
checked: false,
disabled: false,
icon: null,
text: "Option three",
value: "3"
},
{
checked: false,
disabled: false,
icon: null,
text: "Option four",
value: "4"
}
]
};

displayValue = (val) => {
console.log(val);
}

render() {
return (
<div>
<MDBSelect
color="primary"
options={this.state.options}
selected="Choose your option"
search
searchLabel="Test"
getValue={this.displayValue}
/>
<label>Example label</label>
</div>
);
}
}

export default SelectPage;


Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.8.4
  • Device: PC
  • Browser: Chrome
  • OS: Ubuntu 16
  • Provided sample code: No
  • Provided link: No