Skip to content

fix(ui5-list): show busy indicator over the list #2684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 41 additions & 42 deletions packages/main/src/List.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,53 +2,52 @@
class="ui5-list-root"
@focusin="{{_onfocusin}}"
@keydown="{{_onkeydown}}"
@scroll="{{_onScroll}}"
>
<!-- header -->
{{#if header.length}}
<slot name="header" />
{{/if}}
{{#if shouldRenderH1}}
<header id="{{headerID}}" class="ui5-list-header">
{{headerText}}
</header>
{{/if}}
<div class="ui5-list-scroll-container" @scroll="{{_onScroll}}">
<!-- header -->
{{#if header.length}}
<slot name="header" />
{{/if}}
{{#if shouldRenderH1}}
<header id="{{headerID}}" class="ui5-list-header">
{{headerText}}
</header>
{{/if}}

{{#if hasData}}
<div id="{{_id}}-before" tabindex="0" class="ui5-list-focusarea"></div>
{{/if}}

{{#if hasData}}
<div id="{{_id}}-before" tabindex="0" class="ui5-list-focusarea"></div>
{{/if}}
<ul id="{{_id}}-listUl"
class="ui5-list-ul"
role="{{accRole}}"
aria-label="{{ariaLabelТxt}}"
aria-labelledby="{{ariaLabelledBy}}"
aria-multiselectable="{{isMultiSelect}}"
>
<slot></slot>

<ul id="{{_id}}-listUl"
class="ui5-list-ul"
role="{{accRole}}"
aria-label="{{ariaLabelТxt}}"
aria-labelledby="{{ariaLabelledBy}}"
aria-multiselectable="{{isMultiSelect}}"
>
<slot></slot>
{{#if showNoDataText}}
<li id="{{_id}}-nodata" class="ui5-list-nodata" tabindex="{{noDataTabIndex}}" style="list-style-type: none;">
<div id="{{_id}}-nodata-text" class="ui5-list-nodata-text">
{{noDataText}}
</div>
</li>
{{/if}}
</ul>

{{#if showNoDataText}}
<li id="{{_id}}-nodata" class="ui5-list-nodata" tabindex="{{noDataTabIndex}}" style="list-style-type: none;">
<div id="{{_id}}-nodata-text" class="ui5-list-nodata-text">
{{noDataText}}
</div>
</li>
{{#if footerText}}
<footer id="{{_id}}-footer" class="ui5-list-footer">
{{footerText}}
</footer>
{{/if}}
</ul>

{{#if footerText}}
<footer id="{{_id}}-footer" class="ui5-list-footer">
{{footerText}}
</footer>
{{/if}}

{{#if showBusy}}
<div class="ui5-list-busy-row">
<ui5-busyindicator ?active="{{busy}}" size="Medium" class="ui5-list-busy-ind"></ui5-busyindicator>
</div>
{{/if}}
{{#if hasData}}
<div id="{{_id}}-after" tabindex="0" class="ui5-list-focusarea"></div>
{{/if}}
</div>

{{#if hasData}}
<div id="{{_id}}-after" tabindex="0" class="ui5-list-focusarea"></div>
{{/if}}
<div class="ui5-list-busy-row">
<ui5-busyindicator ?active="{{busy}}" size="Medium" class="ui5-list-busy-ind"></ui5-busyindicator>
</div>
</div>
7 changes: 1 addition & 6 deletions packages/main/src/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import ListTemplate from "./generated/templates/ListTemplate.lit.js";
// Styles
import listCss from "./generated/themes/List.css.js";

const BUSYINDICATOR_HEIGHT = 48; // px
const INFINITE_SCROLL_DEBOUNCE_RATE = 250; // ms

/**
Expand Down Expand Up @@ -389,10 +388,6 @@ class List extends UI5Element {
return !this.hasData && this.noDataText;
}

get showBusy() {
return this.busy || this.infiniteScroll;
}

get isMultiSelect() {
return this.mode === ListMode.MultiSelect;
}
Expand Down Expand Up @@ -763,7 +758,7 @@ class List extends UI5Element {
}
this.previousScrollPosition = scrollTop;

if (scrollHeight - BUSYINDICATOR_HEIGHT <= height + scrollTop) {
if (scrollHeight <= height + scrollTop) {
this.fireEvent("load-more");
}
}
Expand Down
23 changes: 15 additions & 8 deletions packages/main/src/themes/List.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,26 @@
border-bottom: 0;
}

:host([busy]) {
opacity: 0.72;
}

:host([busy]) .ui5-list-busy-row {
position: absolute;
top: 50%;
left: 50%;
}

.ui5-list-root {
width: 100%;
height: 100%;
position: relative;
box-sizing: border-box;
}

.ui5-list-scroll-container {
overflow: auto;
height: 100%;
}

.ui5-list-ul {
Expand Down Expand Up @@ -84,11 +98,4 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}

.ui5-list-busy-row {
display: flex;
align-items: center;
height: var(--_ui5_list_busy_row_height);
justify-content: center;
}
}
5 changes: 3 additions & 2 deletions packages/main/test/pages/List.html
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,16 @@ <h3 id="infoLbl">Items 3/3</h3>
var itemsLoadedTotal = 0;
var itemsToLoad = 5;
var loadedCount = 0;
infiniteScrollEx.addEventListener("loadMore", function(e) {

infiniteScrollEx.addEventListener("ui5-load-more", function(e) {
var el = infiniteScrollEx;
el.busy = true;

setTimeout(function() {
insertItems(el, 3);
el.busy = false;
result.textContent = (++loadedCount) + " times " + (itemsLoadedTotal += itemsToLoad);
}, 200);
}, 1000);
});

</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/main/test/pages/List_test_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ <h2 id="testHeader">Test aria</h2>
})

btnTrigger.addEventListener("click", function(e) {
var scrollableContiner = infiniteScrollEx.shadowRoot.querySelector(".ui5-list-root");
var scrollableContiner = infiniteScrollEx.shadowRoot.querySelector(".ui5-list-scroll-container");
scrollableContiner.scroll(0, scrollableContiner.scrollHeight);
});

Expand Down