Unable to display all items of Polymer iron-list - polymer

I'm trying out Polymer for the first time.
I have the following css on the index file:
body {
margin: 0;
font-family: 'Roboto', 'Noto', sans-serif;
line-height: 1.5;
height: 100vh;
background-color: #eeeeee;
}
You can see that the height is explicitly sized.
Then, there's the CSS of the page I'm having issues with iron-list:
:host {
padding: 10px;
display: flex;
flex-direction: column;
height: 100vh;
#apply(--paper-font-common-base);
}
iron-list {
flex: 1 1 auto;
--iron-list-items-container: {
max-width: 800px;
margin: auto;
margin-top: 5px;
margin-bottom: 60px;
border-bottom: 1px solid #ddd;
};
}
You can also see that I'm trying to use flexbox for the height of the iron-list.
I have a simple iron-ajax to populate the list. Theres 81 records on the JSON file.
<iron-ajax id="getVehiclesAjax"
url="../data/vehicles.json"
handle-as="json"
auto
on-response="handleVehiclesResponse"
on-error="handleVehiclesError"></iron-ajax>
The list is also pretty simple:
<iron-list id="list" scroll-target="document" items="[[vehicles]]" as="item" selection-enabled>
<template>
<div>
<div class$="[[getClassForItem(item, selected)]]" tabindex$="[[tabIndex]]">
<div class="pad">
<div class="primary-text">[[item.modelo]]</div>
<div class="shortText">[[item.placa]]</div>
<div class="longText">[[item.chassi]]</div>
</div>
</div>
</div>
</template>
</iron-list>
Expected outcome
The iron-list should render all items, after all, the size is explicitly sized on the parent component, and the scrolltarget on the list is defined to the document. Also, the list has the flexbox setting on the css.
https://elements.polymer-project.org/elements/iron-list
Actual outcome
When I load the page, only 27 records are rendered, although the list height is sized accordingly with the rest of the elements that are not appearing.
I tried to add a button and call this: this.$.list.fire('iron-resize');
But it didn't worked. Resizing the window manually also doesn't do anything.
The only thing that worked, was removing this attribute from the iron-list:
scroll-target="document"
But if I remove it, there's a scrollbar showing for the iron-list, and a scrollbar for the document...
How can I solve this? I want only one scrollbar (document) and the items to be always rendered...

I managed to fix it. Digging up the code, I've found this property:
has-scrolling-region
... on the app-header-layout that was encapsulating all iron-pages. I removed it and now everything works as expected, the rendering of items as I scroll, and only one scrollbar (on the owner document).

Related

Blazor virtualization with row grouping

Im creating a grouped list with sticky header. Really would like to use virtualization with it. But the virtualization doesnt work when i set fixed height and overflow on the top level table-content-container. Virtualization only works when fixed height and overflow is set to group-body-container.
Here's the html i got what does not work:
<div class="table-container">
<div class="table-header grid-row-template">
<div class="header-item">Id</div>
<div class="header-item">Name</div>
</div>
<div class="table-content-container" style="height:50vh; overflow-y:scroll">
#foreach (DataGroup group in dataGroups)
{
<div class="group-header">
<MudToggleIconButton
#bind-Toggled="#group.IsExpanded"
Icon="#Icons.Filled.ExpandMore"
Color="Color.Secondary"
ToggledIcon="#Icons.Filled.ExpandLess"
Size="Size.Small"
ToggledSize="Size.Small"/>
<MudText Color="#Color.Primary">#group.GroupName</MudText>
</div>
#if (group.IsExpanded)
{
<div class="group-body-container">
<Virtualize Items="group.DataRow" Context="row" ItemSize="20">
<div class="grid-row-template data-row">
<div class="data-item">#row.Id</div>
<div class="data-item">#row.Name</div>
</div>
</Virtualize>
</div>
}
}
</div>
</div>
Here the virtualization works: https://try.mudblazor.com/snippet/GEcwagOjgXcmYqFL
Here its not working: https://try.mudblazor.com/snippet/GawcYUuNUXbCiTTY
The goal would be to have the virtualization working with the second example, when scrolled only the top header would be "sticky".
EDIT:
Here's recording of what i would like to achieve but with working virtualization (https://try.mudblazor.com/snippet/GawcYUuNUXbCiTTY):
Is this even possible with blazors virtualization component?
It is because the Virtualize component needs a limiting height - either explicit or implicit. As you have it now, each Virtualize can just grow to consume as much space as it needs.
You can make your container use flexbox and your group container have a min/max height of 100% to achieve this:
.table-content-container {
display: flex;
flex-direction: column;
gap:0;
}
.group-body-container {
min-height: 100%;
max-height: 100%;
overflow: auto;
}
Updated demo #2 where the expanded group matches the container height - but without more information about what you are trying to do this could go on forever....:
https://try.mudblazor.com/snippet/wOQwEKbUdhZHlbiE
To round things off - I do not recommend this design, but to show it is possible, you can also hide the scrollbars on the expanded/virtualised groups with CSS
.group-body-container {
min-height: 100%;
max-height: 100%;
overflow: auto;
}
.group-body-container {
scrollbar-width: none; /* Firefox */
}
.group-body-container::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
Here is a demo: https://try.mudblazor.com/snippet/cammugcNEmPoITgg - with a scrollbar only on the main container, so you can only scroll the virtualized groups contents with mousewheel/touch - which is why I don't like it.

Apply the siblings selector when the second operand has "hidden" attribute

Intro
The vue-slide-up-down plugin appends the attribute hidden to target element to hide it. According documentation, this method is preferred:
"use-hidden" property
Whether to apply the "hidden" attribute to the element when closed.
Defaults to true. This hides the component from the screen and from
assistive devices. The internal elements of the component are
completely invisible, and cannot be focused on (by a keyboard or
assistive device). (This is probably what you want!) If you need, set
this property to false to not use the hidden attribute. This could be
used if you wanted to have a min-height requirement on your component.
Note that this can create accessibility issues, specifically for users with a keyboard or screen reader.
🌎 Source
The problem is the element with hidden attribute obeys to Schrödinger paradox: "this elements is existing, but in the same time not existing". Below example shows what it means.
Target
When the ".ControlsGroup" (designated by blue) is visibly last, it must provide the vertical space l1 below self inside ".Container" (designated by light yellow):
When the ".ErrorsContainer" (designated by orange) is visible, it must retire l2 px from ".ControlsGroup" and provide vertical space l3 below self:
The usage of padding-bottom of container is not allowed because basically we don't know at advance what will be placed inside ".ControlsGroup", so each element MUST know:
How much to retire from specific previous element
How much of vertical space it needs to provide below self when going last.
<div class="Container">
<div class="ControlsGroup"></div>
<div class="ErrorsContainer"></div>
</div>
Problem
When ErrorsContainer is visible, everything is all right: in below example, l2 is 24px and l3 is 36px:
.Container {
background: #FFECB3;
overflow: auto;
}
.ControlsGroup {
height: 300px;
background: #03A9F4;
}
.ErrorsContainer {
height: 40px;
background: #FF9800;
margin-bottom: 36px;
}
.ControlsGroup + .ErrorsContainer {
margin-top: 24px;
}
🌎 Fiddle
Now, if to add hidden attribute to .ErrorsContainer, no l1 space (between bottom of .ControlsGroup and bottom of .Container) will be:
🌎 Fiddle
Let's try to add below CSS rule that means "when .ErrorsContiner with attribute hidden going after .ControlsGroup, push it to 12px (l3)":
.ControlsGroup + .ErrorsContainer[hidden="hidden"] {
margin-bottom: 12px;
}
Nothing will change. The effect like .ErrorsContainer does not exist.
Next, lets try to add below rule that means "When ControlsGroup going last, make 12px of extra space inside the parent":
.ControlsGroup:last-child {
margin-bottom: 12px;
}
Nothing will change because .ErrorContainer actually exists and it's the last child.
Now how to define the l3 when .ErrorsContainer is hidden?
We can do some math here and consider x where l1 + x = l2. The idea is to always have the l1 and when the ErrorsContainer is visible we add to it a margin-top equal to x to get l2 instead of l1. I will also use flexbox to avoid margin collapsing and make sure the margin add and not collapse.
I am using CSS variables to illustrate but it's not mandatory:
.Container {
--l1:30px;
--x:-15px; /* so l2 = 15px */
--l3:10px;
background: #FFECB3;
display:flex;
flex-direction:column;
overflow: auto;
border:2px solid;
margin:5px;
}
.ControlsGroup {
height: 100px;
background: #03A9F4;
}
.ErrorsContainer {
height: 40px;
background: #FF9800;
margin:var(--x) 0 var(--l3);
}
.ControlsGroup {
margin-bottom:var(--l1);
}
<div class="Container">
<div class="ControlsGroup"></div>
<div class="ErrorsContainer" hidden></div>
</div>
<div class="Container">
<div class="ControlsGroup"></div>
<div class="ErrorsContainer"></div>
</div>

How to make the HTML occupie the whole page using Angular 9?

When I run the following lines using just HTML and CSS it runs as I want it, with the header having no margins:
*{
margin: 0;
padding: 0;
}
.header{
background-color: purple;
width: 100%;
height: 80px;
}
<div class='header'>
<h1>Any text</h1>
</div>
But in Angular 9, when I write the same code on a component's HTML and CSS files, it does't occupies the whole page, it have a margin of some pixels instead. How can I fix this?
Angular add own tags so check with DevTool to see if have angular host tags and if your style is correctly added to component or global.

how to set overflow-y to bootstrap-vue table's cell or row

Hello friend i am using Bootstrap-vue to display my data that query from database and i want it to display with the overflow-y like thisenter image description here
so how should i do. please tell me if you guy know how to solve it and here it is my code
<b-table
:items="search_transfer"
:fields="columnsheader"
:current-page="currentPage"
:per-page="perPage"
class="tbsearch"
></b-table>
and here it is what i get.
enter image description here
Hi simple solution is to make it display:inline-block;
add the below css to it
.tbsearch > tbody > tr > td:nth-child(4){
height: 65px;
overflow: auto;
display: inline-block;
}
Table cells in general can be a pain to apply some stylings to (due to their default display: table-cell)
Based on your first image, it looks like they are using a wrapper element around their cell content (based on the padding present around the outside of the scrollable area).
Use a custom slot for the cell rendering, and wrap your content in a <div> element that has your overflow-y class:
<template>
<b-table
:items="search_transfer"
:fields="columnsheader"
:current-page="currentPage"
:per-page="perPage"
>
<!--
I am making an assumption that the field you want to scroll is `description`
-->
<template v-slot:cell(description)="scope">
<div class="my-cell-overflow-y">
{{ scope.value }}
</div>
</template>
</b-table>
</template>
<style>
.my-cell-overflow-y: {
max-height: 2rem;
overflow-y: auto
}
</style>
See https://bootstrap-vue.js.org/docs/components/table#custom-data-rendering for details on custom data cell rendering.

paper-header-panel inside iron-pages shows no content

I am building an SPA polymer 1.0 app that looks like this:
<iron-pages attr-for-selected="data-page"
selected="{{page}}">
<div data-page="home">
<paper-header-panel mode="{{mainMode}}">
<profile-toolbar></profile-toolbar>
<div class="content">
<search-menu></search-menu>
</div>
</paper-header-panel>
</div>
<div data-page="search">
<paper-drawer-panel ...>
...
</paper-drawer-panel>
</div>
</iron-pages>
<profile-toolbar> is a custom element that contains a <paper-toolbar>. If I leave out the <paper-header-panel> it works, but there's a padding and the scrolling doesn't work right. So I added a <paper-header-panel>.
The second page also contains a <paper-header-panel> inside the drawer and works correctly, but I can't make the first page display anything if it contains a <paper-header-panel>. What am I missing?
Try adding following css class to divs that are direct parents of your paper-header-panels:
.content {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
Here is a solution you might try.
Note this open bug that has (apparently) been resolved for all except iOS (Safari).