Mat select options showing behind the Dialog - autocomplete

I am including form inputs, mat select with options and autocomplete field with options too into a matDialog box.
The problem is that the options are showing behind the Dialog. I’ve already came across those solutions solution1 but did'nt solve this problem.
here is my code:
<mat-form-field class="wrapField">
<mat-select (selectionChange)="selectChange($event)" formControlName="product" placeholder="Alle Produkte">
<mat-option *ngFor="let product of products" value="{{product.id}}">{{product.nummer}}</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field class="wrapTime">
<input matInput placeholder="Startzeit" [formControl]="myControl" [matAutocomplete]="auto" formControlName="startTime" required>
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let option of filteredOptions | async" [value]="option">
{{option}}
</mat-option>
</mat-autocomplete>
</mat-form-field>
et here is the style.css file:
.cdk-global-overlay-wrapper, .cdk-overlay-container {
z-index: 99999 !important;
}
Any ideas how to fix that ?

I too had the same issue. As you have found out, this bug is due to the conflicts of z-indices. So I put the following CSS in my global.css which solved the issue:
.cdk-overlay-container, .cdk-overlay-pane {
z-index: 9999 !important;
}

Had the same issue and none of the answers (also from different questions) worked for me.
The only answer that was efficient is here where #Zahema is saying:
Not recommeding the z-index: 99999 !important; AT ALL. It's a very
exteme soultion that should be used only as a last resort.
In my case it was that the modal was opened in a non-standard way. If
you open it using MatDialog service you shouldn't find any issues. If
there is then your code is what introduced them, try not to hack your
way into a fix.
This solution worked perfectly for me.

Related

Ionic - Limits of what can be pushed into [innerHTML]

I'm a volunteer at a Coffee Shop. I've built an app that presents the drink recipe to the barista. Here's a quick snapshot:
The data come from a firebase realtime database. Here's a snippet from that database:
What I want to do is to put some HTML into the instructions to format it for easy reading. I do that by binding the content in the template file to [innerHTML] as shown below:
<ion-item>
<ion-grid>
<ion-row *ngIf="!item.temperature">
<ion-col>
<ion-label><strong>Instructions</strong></ion-label>
</ion-col>
</ion-row>
<ion-row>
<ion-col>
<h5 *ngIf="this.compactMode">
<span [innerHTML]="item.instructions"></span>
</h5>
<span *ngIf="!this.compactMode" [innerHTML]="item.instructions">
</span>
</ion-col>
<ion-col *ngIf="item.image"
><ion-img
(click)="onClickImage(item.image)"
src="{{item.image}}"
></ion-img
></ion-col>
</ion-row>
</ion-grid>
</ion-item>
THE PROBLEM
This works really well for <b> <ol> <ul> <li> <br> and so on. But it does not work for <ion-checkbox> nor <input type="checkbox"> The input tags get filtered out somewhere before being presented.
SECURITY
I'm aware that putting HTML into a database can increase my security surface, so I'm using sanitizer to filter the HTML and then I attempt to add the after the fact. Here's how I do it:
stringFormat(inputString: string) {
const re1 = /\[\]/gi;
let returnString = this.sanitizer.sanitize(1, inputString);
returnString = returnString.replace(re1, '<ion-checkbox id=\'input\'></ion-checkbox>');
return returnString;
}
You'll notice that I first sanitize the string, and then I do a substitution, replacing [] with the checkbox.
(In case you're interested, I'm just making a opening/closing checklist and it would be nice if people could touch the checkbox after they've completed a task... I don't plan to store the checkbox values, I just want the checkbox user experience.)
I have checked that item.instructions in fact includes the substituted string in the item object, but when rendered by ionic/angular, the actual text seems to have filtered out anything but vanilla HTML tags.
Finally the Question
So here's the question: Are there some sort of limits to what can be inserted into the DOM using [innerHTML] binding? Am I overthinking this?
Thanks.
After reading https://developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML, I've concluded that there really is not a safe way to do this using the approach suggested above.
Instead of embedding HTML in the database, I'm going to set up an array of paragraphs in the item.instructions fields of the database. Each element in the array can have a key:value pair to indicate if the element represents a plain paragraph, or a checkbox.
Then I can iterate through the array of instructions (*ngFor), and for each instruction I can check the instruction type (<div *ngIf="item.type===...>) to determine whether to wrap the text with an <ion-text> or an <ion-checkbox>.

How to locate multiple text element within class in Protractor?

For on my test i need to verify highlighted text (Lexington, KY) using my protractor test.
<li id="address" class="list">
<div class="content">
<small class="mb-1">
<span>
Suite # 278
<br>
</span>
**Lexington, KY**
</small>
</li>
How to verify highlighted text using css OR cssContainingText locator?
Actually Protractor creators have put great documentation in place , and pls read it thoroughly to gain good knowledge on usage of css & cssContainingText. I will answer your question in short here - Use element(by.cssContainingText('.content','Lexington'))
UPDATE 1:
In case you want to add an assertion .. do this - expect(element(by.cssContainingText('.content','Lexington'))).toContain('Lexington, KY')
For one I am confused because it seems like you are never closing the content div...is it closed after the li is closed?
Anyway...I would simply change the HTML so that you don't need some crazy convoluted mess of a selector. I would do it like this:
<li id="address" class="list">
<div class="content">
<small class="mb-1">
<span>
Suite # 278
<br>
</span>
<cityState>Lexington, KY</cityState>
</small>
</li>
function checkCityState(){
return element(by.tagName('cityState')).getText();
}
expect(checkCityState()).toBe('Lexington, KY');

Select2 multiple box placeholder not showing on hide then make it visible case

I am using select2() in <select multiple>. What I have is a placeholder in that select. What I am doing is initially I am hiding the select containing div and then I am making it visible. In this case initially placeholder not showing.
If we are not doing this hide and block thing then it is working fine.
FIDDLE
(EDITED) Sorry I read the question wrong. I thought it was about regular selects not multiples.
I've checked your fiddle.
This contains 2 multiples. <select multiple id="e1" style="width:100%" multiple data-placeholder="Choose country(s)*">. I don't know if this is intentional. But you should remove one.
The input element select2 has it's width set to 0px when you set display: none. You need to increase the width to an appropriate size.
I added $('.select2-input, .select2-default', $("#divid")).css('width', '100%'); to your code and this solved your issue.
Snippet (non-functional, needs select2 libraries):
$("#e1").select2();
$('.select2-input, .select2-default', $("#divid")).css('width', '100%');
$("#divid").css("display","block");
<div id="divid" style="display:none;">
<select id="e1" style="width:100%" multiple data-placeholder="Choose country(s)*">
<option value="AL">Alabama</option>
<option value="Am">Amalapuram</option>
<option value="An">Anakapalli</option>
<option value="Ak">Akkayapalem</option>
<option value="WY">Wyoming</option>
</select>
</div>
just add this class in your .css file.
.select2-search__field{width:100% !important;}

Traverse to get to innerHTML

Using Selenium IDE, I need to verify the text "Schedule Entry Worksheet for ZBW - Boston Center" is present. I'd like to use AssertTextPresent to do this. I'm using Firebug to identify the path to the element.
Here's what I've done so far in IDE:
Command: assertTextPresent
Target: xpath=//html/body/div[7]/div[2]/div/div/span
Value: Schedule Entry Worksheet for ZBW - Boston Center
However, I'm getting "[error] false" in the log section. Does anyone know what I'm doing incorrectly?
Below is a snippet HTML for the page:
<div id="worksheet_div" style="display: inline;">
<div class="fg1" style="width: 2010px;">
<div class="fgt">
<span style="padding-right: 10px; background-color: #E3EFFF;">Schedule Entry Worksheet for ZBW - Boston Center</span>
</div>
does it matter where the text is or just that it is somewhere? if it is the latter you could do something as simple as
css=span
if position on the page matter then need to add more structure to it
css=.fgt span
or similar.
it is also useful to use the firefinder plugin for firefox to debug xpath and css

jQuery select image in div if image parent does't have a certain class

Wordpress wraps images with captions in a div with a class of .wp-caption.
I'm looking for a way to select images that don't have this div so I can wrap them in different div. (to keep a consistent border around all the images)
<div class="blog-post-content">
<div id="attachment_220" class="wp-caption alignleft" style="width: 310px">
<img class="size-medium wp-image-220" src="/path/to/image" alt="" width="300" height="280" />
<p class="wp-caption-text">Caption Text</p>
</div>
<p>This is the body of the post</p>
</div>
To test my selector, I'm just trying to add a green border. I can handle the .wrap() once the selector is working.
The most promising of my attempts is:
$('.blog-post-content img').parent('div:not(".wp-caption")').css('border', '2px solid green');
... but no luck.
How about this: (untested)
$('.blog-post-content img').filter(function(){
return !$(this).parents('div').hasClass('wp-caption');
}).css('border', '2px solid green');
try:
$('.blog-post-content img').parent(':not("div.wp-caption")')
Not if what Matti says abotu the a element in the hierarchy then the above wont work.
I know this question was asked a long time ago, but I would like to suggest the following:
$('.blog-post-content img').closest('div:not(".wp-caption")')
Untested, but I think that should work, and is shorter than the answer above that works. Using closest means the a is ignored.