Setup gr-change-list to use gr-cursor-manager
Cursing in the change list predates the standard cursor manager and thus handled cursing manually. When the [enter] key handler was reworked to defer to the browser's native focus (issue 7294) the enter key behavior stopped working in change lists because the focus was not being set by the cursor. With this change, change lists use the cursor manager that is configured to set focus, allowing the [enter] key to safely work as before without interfering with issue 7294. Section query link URL generation is upgraded to use Gerrit.Nav. Bug: Issue 7493 Change-Id: Ia70cf75a555b6aee54e2740fa653c1568eba1525
This commit is contained in:
@@ -22,6 +22,7 @@ limitations under the License.
|
|||||||
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
<link rel="import" href="../../../bower_components/polymer/polymer.html">
|
||||||
<link rel="import" href="../../../styles/gr-change-list-styles.html">
|
<link rel="import" href="../../../styles/gr-change-list-styles.html">
|
||||||
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
|
<link rel="import" href="../../core/gr-navigation/gr-navigation.html">
|
||||||
|
<link rel="import" href="../../shared/gr-cursor-manager/gr-cursor-manager.html">
|
||||||
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
||||||
<link rel="import" href="../gr-change-list-item/gr-change-list-item.html">
|
<link rel="import" href="../gr-change-list-item/gr-change-list-item.html">
|
||||||
<link rel="import" href="../../../styles/shared-styles.html">
|
<link rel="import" href="../../../styles/shared-styles.html">
|
||||||
@@ -101,11 +102,17 @@ limitations under the License.
|
|||||||
visible-change-table-columns="[[visibleChangeTableColumns]]"
|
visible-change-table-columns="[[visibleChangeTableColumns]]"
|
||||||
show-number="[[showNumber]]"
|
show-number="[[showNumber]]"
|
||||||
show-star="[[showStar]]"
|
show-star="[[showStar]]"
|
||||||
|
tabindex="0"
|
||||||
label-names="[[labelNames]]"></gr-change-list-item>
|
label-names="[[labelNames]]"></gr-change-list-item>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</table>
|
</table>
|
||||||
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
||||||
|
<gr-cursor-manager
|
||||||
|
id="cursor"
|
||||||
|
index="{{selectedIndex}}"
|
||||||
|
scroll-behavior="keep-visible"
|
||||||
|
focus-on-move></gr-cursor-manager>
|
||||||
</template>
|
</template>
|
||||||
<script src="gr-change-list.js"></script>
|
<script src="gr-change-list.js"></script>
|
||||||
</dom-module>
|
</dom-module>
|
||||||
|
@@ -113,6 +113,10 @@
|
|||||||
keydown: '_scopedKeydownHandler',
|
keydown: '_scopedKeydownHandler',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
observers: [
|
||||||
|
'_sectionsChanged(sections.*)',
|
||||||
|
],
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iron-a11y-keys-behavior catches keyboard events globally. Some keyboard
|
* Iron-a11y-keys-behavior catches keyboard events globally. Some keyboard
|
||||||
* events must be scoped to a component level (e.g. `enter`) in order to not
|
* events must be scoped to a component level (e.g. `enter`) in order to not
|
||||||
@@ -194,7 +198,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
_sectionHref(query) {
|
_sectionHref(query) {
|
||||||
return `${this.getBaseUrl()}/q/${this.encodeURL(query, true)}`;
|
return Gerrit.Nav.getUrlForSearchQuery(query);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -234,10 +238,7 @@
|
|||||||
this.modifierPressed(e)) { return; }
|
this.modifierPressed(e)) { return; }
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// Compute absolute index of item that would come after final item.
|
this.$.cursor.next();
|
||||||
const len = this._computeItemAbsoluteIndex(this.sections.length, 0);
|
|
||||||
if (this.selectedIndex === len - 1) { return; }
|
|
||||||
this.selectedIndex += 1;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleKKey(e) {
|
_handleKKey(e) {
|
||||||
@@ -245,8 +246,7 @@
|
|||||||
this.modifierPressed(e)) { return; }
|
this.modifierPressed(e)) { return; }
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (this.selectedIndex === 0) { return; }
|
this.$.cursor.previous();
|
||||||
this.selectedIndex -= 1;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_handleOKey(e) {
|
_handleOKey(e) {
|
||||||
@@ -317,5 +317,12 @@
|
|||||||
_getListItems() {
|
_getListItems() {
|
||||||
return Polymer.dom(this.root).querySelectorAll('gr-change-list-item');
|
return Polymer.dom(this.root).querySelectorAll('gr-change-list-item');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_sectionsChanged() {
|
||||||
|
// Flush DOM operations so that the list item elements will be loaded.
|
||||||
|
Polymer.dom.flush();
|
||||||
|
this.$.cursor.stops = this._getListItems();
|
||||||
|
this.$.cursor.moveToStart();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
@@ -473,16 +473,6 @@ limitations under the License.
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test('_sectionHref', () => {
|
|
||||||
assert.equal(
|
|
||||||
element._sectionHref('is:open owner:self'),
|
|
||||||
'/q/is:open+owner:self');
|
|
||||||
assert.equal(
|
|
||||||
element._sectionHref(
|
|
||||||
'is:open ((reviewer:self -is:ignored) OR assignee:self)'),
|
|
||||||
'/q/is:open+((reviewer:self+-is:ignored)+OR+assignee:self)');
|
|
||||||
});
|
|
||||||
|
|
||||||
test('_computeItemAbsoluteIndex', () => {
|
test('_computeItemAbsoluteIndex', () => {
|
||||||
sandbox.stub(element, '_computeLabelNames');
|
sandbox.stub(element, '_computeLabelNames');
|
||||||
element.sections = [
|
element.sections = [
|
||||||
|
@@ -26,6 +26,9 @@ limitations under the License.
|
|||||||
// - `changeNum`, required, String: the numeric ID of the change.
|
// - `changeNum`, required, String: the numeric ID of the change.
|
||||||
//
|
//
|
||||||
// - Gerrit.Nav.View.SEARCH:
|
// - Gerrit.Nav.View.SEARCH:
|
||||||
|
// - `query`, optional, String: the literal search query. If provided,
|
||||||
|
// the string will be used as the query, and all other params will be
|
||||||
|
// ignored.
|
||||||
// - `owner`, optional, String: the owner name.
|
// - `owner`, optional, String: the owner name.
|
||||||
// - `project`, optional, String: the project name.
|
// - `project`, optional, String: the project name.
|
||||||
// - `branch`, optional, String: the branch name.
|
// - `branch`, optional, String: the branch name.
|
||||||
@@ -136,6 +139,13 @@ limitations under the License.
|
|||||||
return this._generateUrl(params);
|
return this._generateUrl(params);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getUrlForSearchQuery(query) {
|
||||||
|
return this._getUrlFor({
|
||||||
|
view: Gerrit.Nav.View.SEARCH,
|
||||||
|
query,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {!string} project The name of the project.
|
* @param {!string} project The name of the project.
|
||||||
* @param {boolean=} opt_openOnly When true, only search open changes in
|
* @param {boolean=} opt_openOnly When true, only search open changes in
|
||||||
|
@@ -322,6 +322,10 @@
|
|||||||
* @return {string}
|
* @return {string}
|
||||||
*/
|
*/
|
||||||
_generateSearchUrl(params) {
|
_generateSearchUrl(params) {
|
||||||
|
if (params.query) {
|
||||||
|
return '/q/' + this.encodeURL(params.query, true);
|
||||||
|
}
|
||||||
|
|
||||||
const operators = [];
|
const operators = [];
|
||||||
if (params.owner) {
|
if (params.owner) {
|
||||||
operators.push('owner:' + this.encodeURL(params.owner, false));
|
operators.push('owner:' + this.encodeURL(params.owner, false));
|
||||||
|
@@ -226,6 +226,10 @@ limitations under the License.
|
|||||||
'/q/owner:a%2525b+project:c%2525d+branch:e%2525f+' +
|
'/q/owner:a%2525b+project:c%2525d+branch:e%2525f+' +
|
||||||
'topic:"g%2525h"+status:op%2525en');
|
'topic:"g%2525h"+status:op%2525en');
|
||||||
|
|
||||||
|
// The presence of the query param overrides other params.
|
||||||
|
params.query = 'foo$bar';
|
||||||
|
assert.equal(element._generateUrl(params), '/q/foo%2524bar');
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
view: Gerrit.Nav.View.SEARCH,
|
view: Gerrit.Nav.View.SEARCH,
|
||||||
statuses: ['a', 'b', 'c'],
|
statuses: ['a', 'b', 'c'],
|
||||||
|
Reference in New Issue
Block a user