Skip to content

Commit

Permalink
Impl
Browse files Browse the repository at this point in the history
  • Loading branch information
134130 committed May 19, 2023
1 parent 079085f commit 715b9b9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ Thanks for contributing! 🦋🙌
- [](# "command-palette-navigation-shortcuts") Adds keyboard shortcuts to select items in command palette using <kbd>ctrl</kbd> <kbd>n</kbd> and <kbd>ctrl</kbd> <kbd>p</kbd> (macOS only).
- [](# "submission-via-ctrl-enter-everywhere") Enables submission via <kbd>ctrl</kbd> <kbd>enter</kbd> on every page possible.
- [](# "clean-repo-header") [Reduces repository name wrapping by hiding the fork and watch count (they're still on the repository’s home page)](https://user-images.githubusercontent.com/1402241/218252904-6a31a933-41a7-452e-b841-9484e67429a8.png)
- [](# "unified-search") See the issues on the pull requests search.

<!-- Refer to style guide above. Keep this message between sections. -->

Expand Down
28 changes: 28 additions & 0 deletions source/features/unified-search.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as pageDetect from 'github-url-detection';

import features from '../feature-manager.js';
import observe from '../helpers/selector-observer.js';

function addListener(inputElement: HTMLInputElement): void {
const searchForm = inputElement.parentElement;
if (!(searchForm instanceof HTMLFormElement)) {
throw new TypeError('Failed to find Form element');
}

inputElement.addEventListener('change', () => {
searchForm.action = /is:[a-zA-Z]+/.test(inputElement.value)
? searchForm.action.replace(/\/issues$/, '/pulls')
: searchForm.action.replace(/\/pulls$/, '/issues');
});
}

function init(signal: AbortSignal): void {
observe('input#js-issues-search', addListener, {signal});
}

void features.add(import.meta.url, {
include: [
pageDetect.isPRList,
],
init,
});
1 change: 1 addition & 0 deletions source/refined-github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,4 @@ import './features/pr-base-commit.js';
import './features/unreleased-commits.js';
import './features/previous-version.js';
import './features/status-subscription.js';
import './features/unified-search.js';

0 comments on commit 715b9b9

Please sign in to comment.