Commit 727be052 authored by Scott Chen's avatar Scott Chen Committed by Commit Bot

MD Extensions: fix error-console sub-page looking broken.

This CL is the first pass for error-console such that it no longer looks
completely broken, as well as fixing keyboard navigation. There will be 
follow-up CLs to bring it closer to the design spec as well as adding the
missing dev-tool buttons.

Bug: 768580
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I15d85e0ebe946b11a9a7aaf9f471ba22fe705a97
Reviewed-on: https://chromium-review.googlesource.com/685988
Commit-Queue: Scott Chen <scottchen@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#505257}
parent fd0041e9
......@@ -12,6 +12,7 @@
color: var(--paper-grey-800);
display: flex;
font-family: monospace;
overflow: auto;
white-space: pre;
}
......
......@@ -14,22 +14,35 @@
<dom-module id="extensions-error-page">
<template>
<style include="cr-icons cr-hidden-style">
:host {
display: block;
height: 100%;
overflow: auto;
}
#main {
background-color: white;
height: 800px;
width: 90%;
display: flex;
flex-direction: column;
margin: auto;
min-height: 100%;
width: 640px;
}
#heading {
color: var(--paper-grey-600);
height: 40px;
margin-bottom: 30px;
padding: 8px 12px 0;
@apply(--cr-title-text);
}
#errors-list {
min-height: 100px;
padding: 0 10px;
padding: 0 var(--cr-section-padding);
}
#content-view {
padding: 0 var(--cr-section-padding);
}
.error-item {
......@@ -39,6 +52,10 @@
margin: 5px 0;
}
.error-item button[is='paper-icon-button-light'] {
-webkit-margin-end: 0;
}
.error-item.selected {
background-color: #ccc;
}
......@@ -68,16 +85,18 @@
</button>
<span>$i18n{errorsPageHeading}</span>
</div>
<iron-list id="errors-list" items="[[calculateShownItems_(data.*)]]">
<iron-list id="errors-list" items="[[calculateShownItems_(data.*)]]"
preserve-focus>
<template>
<div class$="[[computeErrorClass_(selectedError_, item)]]"
<div class$="error-item [[computeErrorClass_(selectedError_, item)]]"
error="[[item]]"
tabindex$="[[tabIndex]]"
on-tap="onErrorItemTap_" on-keydown="onErrorItemKeydown_">
on-tap="onErrorItemAction_" on-keydown="onErrorItemAction_">
<img class$="[[computeErrorIconClass_(item)]]">
<div class="error-message">[[item.message]]</div>
<button is="paper-icon-button-light" class="icon-delete-gray"
on-tap="onDeleteErrorTap_" tabindex$="[[tabIndex]]"></button>
on-tap="onDeleteErrorAction_" tabindex$="[[tabIndex]]"
on-keydown="onDeleteErrorAction_"></button>
</div>
</template>
</iron-list>
......
......@@ -64,6 +64,8 @@ cr.define('extensions', function() {
* @private
*/
calculateShownItems_: function() {
// Render iron-list correctly after data changes.
setTimeout(() => this.$['errors-list'].fire('iron-resize'));
return this.data.manifestErrors.concat(this.data.runtimeErrors);
},
......@@ -98,14 +100,16 @@ cr.define('extensions', function() {
},
/**
* @param {!Event} event
* @param {!Event} e
* @private
*/
onDeleteErrorTap_: function(event) {
// TODO(devlin): It would be cleaner if we could cast this to a
// PolymerDomRepeatEvent-type thing, but that doesn't exist yet.
const e = /** @type {!{model:Object}} */ (event);
this.delegate.deleteErrors(this.data.id, [e.model.item.id]);
onDeleteErrorAction_: function(e) {
if (e.type == 'keydown' && !((e.code == 'Space' || e.code == 'Enter')))
return;
this.delegate.deleteErrors(
this.data.id, [(/** @type {!{model:Object}} */ (e)).model.item.id]);
e.stopPropagation();
},
/**
......@@ -146,7 +150,7 @@ cr.define('extensions', function() {
* @private
*/
computeErrorClass_: function(selectedError, error) {
return selectedError == error ? 'error-item selected' : 'error-item';
return selectedError == error ? 'selected' : '';
},
/**
......@@ -162,17 +166,11 @@ cr.define('extensions', function() {
* @param {!{model: !{item: (!RuntimeError|!ManifestError)}}} e
* @private
*/
onErrorItemTap_: function(e) {
this.selectError_(e.model.item);
},
onErrorItemAction_: function(e) {
if (e.type == 'keydown' && !((e.code == 'Space' || e.code == 'Enter')))
return;
/**
* @param {!{model: !{item: (!RuntimeError|!ManifestError)}}} e
* @private
*/
onErrorItemKeydown_: function(e) {
if (e.key == ' ' || e.key == 'Enter')
this.selectError_(e.model.item);
this.selectError_(e.model.item);
},
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment