-
Notifications
You must be signed in to change notification settings - Fork 8.6k
UX: display search input and open modal on click #32508
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
6b3fc88
UX: display search input and open modal on click
lis2 0bd918b
FIX: modal min height
lis2 f2de2e9
FIX: on mousedown
lis2 50bb719
FIX: linter mouse down
lis2 c784564
FIX: import when not admin
lis2 cb60530
FIX: shortcut hint
lis2 97d0ea3
Update app/assets/javascripts/discourse/app/components/sidebar/panel-…
lis2 4eb6be0
FIX: improvements after code review
lis2 15a54e1
FIX: sort dependencies
lis2 50e1f36
FIX: switch to full page search link
lis2 1e58818
FIX: sort
lis2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
app/assets/javascripts/discourse/app/components/sidebar/search.gjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import Component from "@glimmer/component"; | ||
import { on } from "@ember/modifier"; | ||
import { action } from "@ember/object"; | ||
import { service } from "@ember/service"; | ||
import DButton from "discourse/components/d-button"; | ||
import { translateModKey } from "discourse/lib/utilities"; | ||
import { i18n } from "discourse-i18n"; | ||
|
||
export default class Search extends Component { | ||
@service sidebarState; | ||
|
||
get shouldDisplay() { | ||
return this.sidebarState.currentPanel.searchable; | ||
} | ||
|
||
get sidebarShortcutCombo() { | ||
return `${translateModKey("Meta")}+/`; | ||
} | ||
|
||
@action | ||
onClick(event) { | ||
event?.preventDefault(); | ||
return this.sidebarState.currentPanel.onSearchClick; | ||
} | ||
|
||
<template> | ||
{{#if this.shouldDisplay}} | ||
<div class="sidebar-search"> | ||
<div class="sidebar-search__input-container"> | ||
<DButton | ||
@action={{this.onClick}} | ||
@icon="magnifying-glass" | ||
class="btn-transparent sidebar-search__icon" | ||
/> | ||
{{! template-lint-disable no-pointer-down-event-binding }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need mousedown because mouseup is too late. I want to prevent input to get focus, so when modal is closed, the user cannot type anything into this fake input. |
||
<input | ||
{{on "mousedown" this.onClick}} | ||
placeholder={{i18n "sidebar.search"}} | ||
type="text" | ||
enterkeyhint="done" | ||
class="sidebar-search__input" | ||
/> | ||
<span | ||
class="sidebar-search__shortcut-hint" | ||
>{{this.sidebarShortcutCombo}}</span> | ||
</div> | ||
</div> | ||
{{/if}} | ||
</template> | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need it because importing when I import
admin/components/modal/admin-search
inadmin-sidebar.js
it was failing for non admin users.