Impossible to get an Angular component on the left of another - css

Simple question, but probably a hard answer. I'm doing an Angular 5 app which has multiple components. These are two of them:
ChartPicker
<div>
<span>
<div class="btn-group btn-group-small" *ngIf="available_charts.chart_types.length > 1">
<label *ngFor="let type_key of available_charts.chart_types" class="btn btn-default active" [class]="type_key.name == available_charts.chart_types.selected ? 'active' : ''" (click)="available_charts.selected = type_key.name">
<i class="fa fa-bar-chart" aria-hidden="true"></i>
</label>
</div>
</span>
</div>
GranularityPicker
<div>
<span>
<select [(ngModel)]="config.granularity.selected">
<option [selected]="false" *ngFor="let option of config.granularity.available" [ngValue]="option">
<span class="option-txt"> {{option}} </span>
</option>
</select>
</span>
</div>
Both are quite easy... right? Well, I put them in the app like this, with another component called segments which is located at the left side of the page:
<segments [config]="config"></segments>
<chart-picker [config]="config" class="chart-picker"></chart-picker>
<granularity [config]="config" class="granularity-picker"></granularity>
Chart-picker is before granularity, and the CSS of both classes have some margin to the right side, and a float:right.
... but the chart-picker, the one which should be first, appears the last, at the right of the granularity one.
This makes absolutely no sense. And it doesn't matter what I try to change it the CSS... it just won't work. Any ideas on how to fix this?

Both elements have float:right. The floats are calculated in document order, so the first element ends up floating all the way to the right, then the second one floats next to the first, leaving them in the "wrong" order. You probably want to be using inline or inline-block elements instead of float here.
.r {float:right}
<div class="r">First</div>
<div class="r">Second</div>

Related

Having an Angular Dynamic Form Generator Bootstrap CSS Issue

I am attempting a dynamic form generator based on Angular's Dynamic Forms template using Angular 7 and I'm running into a css issue. I am using Bootstrap 4.0 and I hope it's not an issue where I need to go back to 3.0 (I had a prior issue that involved that, but correct re-coding got it to work in 4.0). If so, please let me know.
Now, here is the way that my app works correctly for my end product. My code to generate the drop downs is:
<div class="row">
<div *ngFor="let question of questions" class="col-md-6 form-group">
<label for="{{question.key}}">{{question.label}}</label>
<span [ngSwitch]="question.controlType">
<select *ngSwitchCase="'dropdown'"
[id]="question.key"
[formControlName]="question.key"
[className]="question.fieldClass">
<option *ngFor="let opt of question.options" [ngValue]="opt.value">{{opt.name}}</option>
</select>
</span>
<span class="help-block error" *ngIf="isFormTouchedAndInvalid(question.key)">{{question.label}} is invalid</span>
</div>
</div>
When this gets rendered to the screen, the drop downs are aligned correctly, with the correct widths, as you can see:
Now, if I follow Angular's method, my main code block will now become:
<div class="row">
<app-question *ngFor="let question of questions" [question]="question" [form]="form"></app-question>
</div>
And my app-question component has the following code:
<div [formGroup]="form">
<div class="col-{{question.colType}}-{{question.colWidth}} form-group">
<label for="{{question.key}}">{{question.label}}</label>
<span [ngSwitch]="question.controlType">
<select *ngSwitchCase="'dropdown'"
[id]="question.key"
[formControlName]="question.key"
[className]="question.fieldClass"
>
<option *ngFor="let opt of question.options" [ngValue]="opt.value">{{opt.name}}</option>
</select>
</span>
<span class="help-block error" *ngIf="isFormTouchedAndInvalid(question.key)">{{question.label}} is invalid</span>
</div>
</div>
When the form renders to the screen it looks like this:
As you can see, the column widths are gone. I'm certain it has something to do with the div tag holding the FormGroup attribute, but that is required for the component to compile and work. I've tried adding it with a span tag, adding the col-md-6 class to the same tag as FormGroup, but I get the same, incorrect CSS rendering.
Is this another Bootstrap 4 issue where I may need to go down to Bootstrap 3 for this to work? If not, what is going on and how can I get the page to correctly render like the first image and yet still be able to use the app-question component in my code?
I believe that the problem is that Angular renders app-question component as a tag <app-question></app-question> and your div tags inside of it have styles relative to that app-question tag, but not the parent <div class="row">. So if you add a class col-md-6(for example) it will cover 50% of the app-question tag, but not the row one.
So if you want the styles to work, you should add the classes here
<div class="row">
<app-question *ngFor="let question of questions"
[question]="question"
[form]="form"
class="col-md-6">
</app-question>
</div>
As an alternative, you can change your app-question component decorator to make it an attribute.
#Component({
selector: '[app-question]'
})
And then use it to any tag you like
<div class="row">
<div app-question
*ngFor="let question of questions"
[question]="question"
[form]="form"
class="col-md-6">
</app-question>
</div>

ARIA: Treat HTML element as a whole

Is there any way to tell an assistive tool to treat an element (e.g: <div>) as a whole, and not split it in child elements?
First example
Using iOS VoiceOver and a with a field on it, it gets splitted into two different elements:
Second example
This elements are splitted in two parts, where the best solution would be read "122 points" and "First position":
<div class="row">
<div class="stat lg col-xs-6">
<span>122</span>
<i class="icon icon-prize" aria-hidden="true"></i>
<h5>Points</h5>
</div>
<div class="stat lg col-xs-6">
<span>1ยบ</span>
<i class="icon icon-prize" aria-hidden="true"></i>
<h5>Position</h5>
</div>
</div>
VoiceOver on iOS does indeed sometimes split a sentence, although your example code actually works fine. I used your code as the first line in the screen shots below and then copied the text without the <a> tag as the second line. The second line gets broken up by VoiceOver but the <a> tag does not.
<span class="label info">
<a href="/round/next">
Next round starts <strong>in 3 days</strong>
</a>
</span>
<br>
Next round starts <strong>in 3 days</strong>
(Note: I have the enhanced outline turned on for VoiceOver so the black outline is probably thicker than what you're used to seeing.)
I found that using role="button" the element is treated as a group and its innerText property is read, but announced as a button.

Selenium Python I am trying to select a drop down from a nested span tag using XPATH or CSS selector

I am trying to work out the XPATH or CSS for the drop down element which seems to be in nested span tags.
I want to find the tag
I can find the text above the drop down but i cannot go down the span tags to get to the drop down element.
I have XPATH to get to the text above the drop down. The XPATH is:
//span[contains(text(), "Select a data preview to import configuration from")]
If i try to use preceding::span[2] it goes too far down.
//span[contains(text(), "Select a data preview to import configuration from")]/preceding::span[2]
The HTML snippet is:
<div class="GPI5XK1CM" style="padding-right: 16px;position:relative;outline:none;" __idx="0" onclick="">
<div style="position:absolute;display:none;"/>
<div>
<span/>
<span>
<span title="" style="font-weight:bold;">Select a data preview to import configuration from</span>
</span>
<span/>
<span>
<span class="" title="" style="display:block;"/>
</span>
<span/>
<span/>
<span/>
<span/>
<span/>
<span>
<span class="" title="None" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;empty-cells:show;">
<select tabindex="-1">
<option selected="selected" value="None">None</option>
<option value="CRMINVALID_07102015">CRMINVALID_07102015</option>
<option value="LADEMO_crm2_Chrome">LADEMO_crm2_Chrome</option>
<option value="LADEMO_CRM_DONOTCHANGE_CHROME">LADEMO_CRM_DONOTCHANGE_CHROME</option>
<option value="LADEMO_ESCR_DO_NO_CHANGE_CHROME">LADEMO_ESCR_DO_NO_CHANGE_CHROME</option>
<option value="Lademo_odb_Data">Lademo_odb_Data</option>
<option value="test">test</option>
</select>
</span>
</span>
</div>
What XPATH or CSS could i use to get to the drop down? CSS is faster, that would be good.
I think I have worked one out now but not sure if it is a good way to do it.
This one works for me:
//span[contains(text(), "Select a data preview to import configuration from")]/preceding::span[1]//../span//../select
First search for a span element with the text Select a data preview to import configuration from
then find the first span tag /preceding::span[1]
then find all of the span tags below the 1st span tag //../span
then find the drop down wherever it is within the span tags //../select
Using //../select if the structure changes it will still work.
Is this the correct way?
Thanks,
Riaz
I've got a couple CSS selectors that you can try. The first one should be enough but if not, the second one should be unique.
"select[tabIndex='-1']"
"span[title='None'] > select[tabIndex='-1']"
you can use following xpath to get all option value:
//span[#title='None']/select/option/text()
An example for CSS. This assumes only one span titled 'None'.
$$("span[title='None']>select>option[value='whateveroptionyouseek']")
You could also probably get away with:
$$("span[title='None'] option[value='whateveroptionyouseek']")

Bootstrap 3 input group not working with select element

I am trying to get an input-group styled properly in Bootstrap 3 with a drop-down selector, using this sample code:
<div class="form-group">
<div class="input-group">
<span class="input-group-btn">
<select class="btn">
<option>USD</option>
<option>GBP</option>
<option>ZAR</option>
</select>
</span>
<input type="text" class="form-control">
<span class="input-group-btn">
<div class="btn btn-default" type="button">Button</div>
</span>
</div>
</div>
It works fine in Bootply (http://www.bootply.com/ZVSunDnXif):
but if I put it into my site (ASP.Net Web Forms) using exactly the same code, it breaks:
I wouldn't mind so much (in vanilla bootstrap it's only lacking the border around the select box), except that I'm using a Bootswatch themed version, which doesn't even align properly:
The css path to the input group is body > form > div #MainBody > div.row > div.col-md-9 > div.form-group.
If I remove the select element, it displays fine, so is there something wrong with how I've defined that?
try adding row class to the form-group div parent of the select element. My select element was breaking the form div and going into another row. Adding the row class kept it inside visually although it is still going outside the html form tag. I am going to post about that separately.

Issue with file upload clickable zone in Firefox with Bootstrap 3

I'm using a template based on Bootstrap 3 and there is a weird display issue with Firefox for file input elements: basically the click area covers a huge part of the page, which means that anything around them cannot be clicked without triggering a file upload.
Here is what I mean by large area (with Firebug, based on the <input type="file"> element):
While with Chrome it's fine:
And with IE it's also fine.
Here is the link to the theme page where you see the issue (only happening to the first type of "advanced file input", where the input element itself is displayed): http://www.keenthemes.com/preview/metronic_admin/components_form_tools.html
And here is the code for the file display:
<div class="fileinput fileinput-new" data-provides="fileinput">
<div class="input-group input-large">
<div class="form-control uneditable-input span3" data-trigger="fileinput">
<i class="fa fa-file fileinput-exists"></i>
<span class="fileinput-filename"></span>
</div>
<span class="input-group-addon btn default btn-file">
<span class="fileinput-new">Select file</span>
<span class="fileinput-exists">Change</span>
<input type="file" name="documents-0">
</span>
Remove
</div>
</div>
Any idea how I can force the input element click zone to stay within its limits on Firefox?
Thanks in advance!

Resources