-
Notifications
You must be signed in to change notification settings - Fork 183
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
Feature: Filter Aliases by Category/Type #1024
Conversation
4b3d643
to
723d50e
Compare
@@ -10,7 +14,7 @@ | |||
} | |||
} | |||
|
|||
&.is-search-active { | |||
&.is-search-visible { | |||
margin-bottom: 4.5rem; |
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.
This is ~72px
. The biggest the spacing-
tokens go is 48px
. Leaving as is.
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.
Self JS review
let currentFilteredByCategoryAliases; | ||
let currentFilteredBySearchAliases; |
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.
let
sniff: This is part of some wild west state management. If we want to flag it for a state.
type object, we can refactor heavily to manage this.
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.
Ugh, some random state
object flying around would be worse than let
anyway. If I can't come up with a refactor in 10-15m I'm fine with keeping let
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.
It's worth exploring later on, when we have even more search going on. When filters get stacked on top of each other, having single point of reference of what should be filtered is helpful.
function toggleAliasSearchBar() { | ||
filterToggleSearchInput.classList.toggle("is-enabled"); | ||
filterContainer.classList.toggle("is-search-active") | ||
filterContainer.classList.toggle("is-search-visible"); |
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.
This class is used to toggle (via CSS) search on mobile/tablet.
static/js/filter.js
Outdated
if (isCategoryFilterActive) { | ||
// aliases = | ||
currentFilteredByCategoryAliases = document.querySelectorAll(".c-alias:not(.is-hidden)"); | ||
} else { | ||
filterContainer.classList.add("is-filtered-by-search"); | ||
} |
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.
This logic block appears throughout this PR and is the crux of the overall feature. Basically when either search or category filtering is active, we have to trunicate the list of available aliases for the OTHER filter to query from. Moving to state management would drop this logic, giving each filtering type the same centralized "target" to query from.
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.
Yeah this feels like we're getting closer and closer to doing a full-on Redux/React refactor sometime.
oppositeCheck: (e) => { | ||
const currentCategory = e.target; | ||
|
||
if (!currentCategory.checked) { | ||
return; | ||
} | ||
|
||
const currentParentCategory = currentCategory.dataset.parentCategory; | ||
|
||
filterCategoryCheckboxes.forEach(checkbox => { | ||
if ( (currentCategory !== checkbox) && (checkbox.dataset.parentCategory === currentParentCategory) && checkbox.checked) { | ||
checkbox.checked = !checkbox.checked; | ||
} | ||
}); |
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.
This an edgecase function to make the checkboxes from the UI behave like radio buttons in certain cases:
Example: User opens filter and selects "show all active aliases" AND "show all disabled aliases". Since this would make the filter…useless, we detect this and toggle off the opposing checkbox.
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 don't see any cardinal sins in this code. There's a couple UX behaviors we might want to do?
- Clicking off the pop-up should close it
- Pressing "Esc" should close the pop-up
- Auto-apply the filtering when the checkbox is clicked (don't wait for the user to click "Apply")
id="active-aliases" | ||
value="" | ||
> | ||
<label class="mzp-c-choice-label" for="active-aliases">Active aliases</label> |
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.
The English strings need to be internationalized ... unless these aren't final UI strings, in which case, ignore.
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.
Strings added.
let currentFilteredByCategoryAliases; | ||
let currentFilteredBySearchAliases; |
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.
Ugh, some random state
object flying around would be worse than let
anyway. If I can't come up with a refactor in 10-15m I'm fine with keeping let
static/js/filter.js
Outdated
if (isCategoryFilterActive) { | ||
// aliases = | ||
currentFilteredByCategoryAliases = document.querySelectorAll(".c-alias:not(.is-hidden)"); | ||
} else { | ||
filterContainer.classList.add("is-filtered-by-search"); | ||
} |
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.
Yeah this feels like we're getting closer and closer to doing a full-on Redux/React refactor sometime.
723d50e
to
368005d
Compare
…results to reset category filter
…lter is user clicks outside of category filter
d8416ca
to
10de4be
Compare
0eb794c
to
6002467
Compare
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.
Looks good to me, just nits :)
Related PR for strings: mozilla-l10n/fx-private-relay-l10n#5 |
TODO:
Auto-apply the filtering when the checkbox is clicked (don't wait for the user to click "Apply")Deferring this for now.Bonus Items/issues:
Questions/Edge cases: (Answered by Eduardo on Aug 18)
What to do when two opposing (on/off) categories are selected?What happens when a user searches while the category filter is active?How do we show a user the category filter is active?