Materialize select not working with custom CSS - drop-down-menu

I have form with a few text and drop-down fields. While text fields are working fine, the dropdown fields are not working as required :
The first option in the drop-down should be disabled but this isn't happening
I have used "required" for select, yet the form gets submitted without alerting. This works fine for text fields though
I feel this is probably something to do with the custom css I have added to change default Materialize theme colors but cannot debug further.
Here is the fiddle link : https://jsfiddle.net/2bxy0gf7/14/
Select HTML
<div class="input-field col col s6 m3 l2">
<select id="FQMreferring_doctor" required="" aria-required="true">
<option value="" selected disabled>Choose your option</option>
<option value="Name1">Name1</option>
<option value="Name2">Name2</option>
</select>
<label for="FQMreferring_doctor">Referring Doctor</label>
</div>
Custom CSS
.dropdown-content li > a,
.dropdown-content li > span {
color: #0067d0 !important;
}
/* label focus color */
.input-field input:focus + label {
color: #0067d0 !important;
}
/* label underline focus color */
.row .input-field input:focus {
border-bottom: 1px solid #00bcd4 !important;
box-shadow: 0 1px 0 0 #00bcd4 !important;
}

Related

Angular Css how to remove border for last child in custom component

I dont want to style border for the last item inside container. how to do this?
I tried
::ng-deep custom-comp .custom-container: last-child {
border-bottom: none; //this is not working
}
<div class="container">
<custom-comp></custom-comp>
<custom-comp></custom-comp>
</div>
custom comp:
<div class="custom-container" style="border-bottom: solid 1px red;">
</div>
Can anyone help me how to style so the last custom-comp doesn't have the border bottom?
thanks
I tried following and it worked.
div.container {
::ng-deep custom-comp:last-child > div {
border-bottom: none;
}
}

SASS - keep button color when clicked (focus, active)

just a styling question for my Rails application.
I made some radio buttons to look like normal buttons. When a button is clicked (and the radio button is checked), I want to keep the button background-color the same as the hover color, but somehow it isn't working. Unfortunately, I'm not the biggest CSS expert.
The color red is just for testing purposes.
HTML:
<label class="btn custom-btn good-outline">
<%= f.radio_button :reception_feed, 2 %>
<%= image_tag "smiley_2.svg", size: '48x48' %>
</label>
CSS (first try):
.good-outline {
border-color: #00e676;
color: #00e676;
&:hover {
background-color: #00e676;
color: white;
}
input[type=radio]:checked + label {
background-color: red;
}
}
CSS (second try):
.good-outline {
border-color: #00e676;
color: #00e676;
&:hover {
background-color: #00e676;
color: white;
}
&:active, &:focus {
background-color: red;
}
}
If I assign the states in my browser, it's working. But it's not working with the click events.
Thanks in advance!
You can do it by changing your markup a little bit.
As I'm not familiar with Rails, I'll use basic HTML in my snippet.
First, why your first try fails.
Your HTML markup:
<label class="btn custom-btn good-outline">
<%= f.radio_button :reception_feed, 2 %>
<%= image_tag "smiley_2.svg", size: '48x48' %>
</label>
Your CSS:
.good-outline { // targets all elements with the class .good-outline (so your label)
border-color: #00e676;
color: #00e676;
&:hover { // targets .good-outline on hover (so your label:hover)
background-color: #00e676;
color: white;
}
input[type=radio]:checked + label {
// targets a label, next direct sibling to an input radio, all children of a .good-outline
// in your markup, it doesn't target anything
background-color: red;
}
}
In short input[type=radio]:checked + label won't target anything in your markup.
Now, let's change the markup:
<input type="radio" id="choice-first" name="radio-choice">
<label for="choice-first">This is my first choice</label>
<input type="radio" id="choice-second" name="radio-choice">
<label for="choice-second">This is my second choice</label>
See how the label is the next direct sibling to it's corresponding input ?
Thanks to that, you can almost keep your css (I've used plain css to be able to add the snippet):
label {
border-color: #00e676;
color: #00e676;
}
label:hover {
background-color: #00e676;
color: white;
}
input[type=radio]:checked + label {
background-color: red;
}
<input type="radio" id="choice-first" name="radio-choice">
<label for="choice-first">This is my first choice</label>
<input type="radio" id="choice-second" name="radio-choice">
<label for="choice-second">This is my second choice</label>
Now it's just a matter of styling to make it look like you want.
You could hide the input and keep just the label, you could add an image in the label and so on...

SASS theme - placeholder style inconsistency

Is it a style bug or how can I make placeholder to be consistent between input with k-textbox style and textbox with icon:
<input class="k-textbox" placeholder="lighter color and shadow on focus" />
<span class="k-textbox k-space-right">
<input placeholder="same color and no shadow on focus" />
<span class="k-icon k-i-search"></span>
</span>
Demo:
https://dojo.telerik.com/UmuwUYeJ
The placeholder color issue could be resolved by adding the k-input class to the nested element:
<input type="text" class="k-input" placeholder="placeholder..."/>
The box-shadow issue is more tricky, as when the nested element is focused, its parent box-shadow should be set. This can be achieved in two ways:
With JavaScript(Dojo example):
$(document).ready(function() {
$(".k-textbox input").focus(function() {
$(this).parent().css("box-shadow", "0 2px 2px 1px rgba(0,0,0,.06)");
});
$(".k-textbox input").focusout(function() {
$(this).parent().css("box-shadow", "none");
});
});
With CSS(Dojo example):
.k-textbox:focus-within {
box-shadow: 0 2px 2px 1px rgba(0,0,0,.06);
}
The above used focus-within select has limited browser support, thus take this into consideration in case you would like to use the CSS approach.

Dropdown list arrow is not working after showing the required field error message

I am displaying some list of ids as follows
<li>
<label> Nest</label>
<select id="NestId" class="Select input-validation-error" name="NestId" data-val-required="Please select nest name." data-val-number="The field Nest ipId must be a number." data-val="true">
<span data-valmsg-for="NestId"></span>
<div class="formError NestshipId" style="top: -69px; left: 202px; opacity: 0.8;">
</li>
The arrow of the ddl is working fine before showing the requirefield erorr msg.Once its shown, some part of it is shadowig over the ddl arrow.
so the arrow is not clickable through the erorr message
When I inspect the code through firebug, I could see the element like this
<li>
<label> Relation</label>
<select id="NestId" class="Select input-validation-error" name="NestId" data-val-required="Please select relation." data-val- number="The field NestId must be a number." data-val="true">
<span data-valmsg-for="NestId"></span>
<div class="formError NestId" style="top: -69px; left: 202px; opacity: 0.8;">
.input-validation-error
{
border: 1px solid #ff0000;
background-color: #ffeeee;
}
<div class="formError NestId" style="top: -69px; left: 202px; opacity: 0.8;">
<div class="formErrorContent">Please select relation.</div>
</div>
I think the arrow is not clickable because of the presence of field message over it.
Can anybody please help me to find a solution for this.
The message should be visible as well as the ddl arrow should work
You can also try setting the position of the error message to the left, in this case it will not be overlapping on the dropdown arrow.
.input-validation-error
{
border: 1px solid #ff0000;
background-color: #ffeeee;
position:relative;
left:20px;
}

how to click on strange select list element?

I have a problem selecting the options in unidentified dropdown menu. Elements of the dropdown appears when i click on dropdown arrow, but I cant click on them, because I don't know their id's or other properties that I can use.
Here is the code. I can't select from select_list with:
on_page(RegistrationPage).id_of_select_list_with_options = "8"
or
#browser.select_list(:name => "field_profile_bday[0][value][day]").select("8")
or
#browser.select_list(:id => "edit-field-profile-bday-0-value-day").select("8")
The error is: Element is not currently visible and so may not be interacted with (Selenium::WebDriver::Error::ElementNotVisibleError)
When I click on combo-button element dropdown list appears, but I can't select elements in it because they appear in combo-selected div after selecting. (Like "Jour" text in combo-selected div, it is there by default)
Here is the html:
<div class="form-item" id="edit-field-profile-bday-0-value-day-wrapper">
<label for="edit-field-profile-bday-0-value-day">Jour : <span class="form-required" title="Ce champ est obligatoire.">*</span></label>
<select name="field_profile_bday[0][value][day]" class="form-select required date-day" id="edit-field-profile-bday-0-value-day" ><option value="" selected="selected">Jour</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option><option value="11">11</option><option value="12">12</option><option value="13">13</option><option value="14">14</option><option value="15">15</option><option value="16">16</option><option value="17">17</option><option value="18">18</option><option value="19">19</option><option value="20">20</option><option value="21">21</option><option value="22">22</option><option value="23">23</option><option value="24">24</option><option value="25">25</option><option value="26">26</option><option value="27">27</option><option value="28">28</option><option value="29">29</option><option value="30">30</option><option value="31">31</option></select>
</div>
<div class="combo-wrapper" style="display: inline-block; width: 61px; height: 24px; " tabindex="0"><div class="combo-button" style="width: 24px; height: 24px; display: inline-block; ">+</div><div class="combo-selected" style="width: 37px; height: 24px; display: inline-block; ">Jour</div></div>
<div class="combo-button" style="width: 24px; height: 24px; display: inline-block; ">+</div>
<div class="combo-selected" style="width: 37px; height: 24px; display: inline-block; ">Jour</div>
"Jour"
</div>
Instead of .select("8"). Try something like:
#browser.select_list(:name => "field_profile_bday[0][value][day]").option(:value, '8').select
or
#browser.select_list(:name => "field_profile_bday[0][value][day]").options[7].select
I think you needed to point to the option element and then use inherent select method. Hope this works. Good Luck!

Resources