Skip to content
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

Correct counting problem with hidden annotations #1734

Merged
merged 8 commits into from Mar 11, 2020
Merged

Correct counting problem with hidden annotations #1734

merged 8 commits into from Mar 11, 2020

Conversation

MrKickkiller
Copy link
Contributor

This pull request fixes the issues laid out in #1733

  • Count was incorrect due to only checking if > 1 when choosing 1 or many.

  • Added specific css to make the link portion a cursor: pointer

  • Locale was modified to be "Show all annotations" & "Toon alle annotaties"

  • Tests were added

Closes #1733 .

Browser should really make this a pointer though. Odd
When there are no error it still had to choose between 1 or many. 0 wasn't an option
@MrKickkiller MrKickkiller changed the title Issue/1733 Correct counting problem with hidden annotations Feb 28, 2020
@chvp chvp added the bug fix label Feb 28, 2020
@chvp chvp added this to the 3.3 milestone Feb 28, 2020
@@ -2,6 +2,10 @@

.code-table {

#annotations-were-hidden a {
cursor: pointer;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add a href="#" to the a element, you don't need any styling for it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I have tried this, but I would have had to insert some more javascript to stop the page from reloading since clicking a <a href="#"></a> will navigate to the same page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just return false; at the end of your event handler or call event.preventDefault();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 for using href without css pointer

@@ -151,6 +151,10 @@ export class CodeListing {

public createHiddenMessage(count: number): HTMLSpanElement {
const span = document.createElement("span");
if (count === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels like this method shouldn't be called if there is no message to show.

Don't call method if error count == 0
@MrKickkiller MrKickkiller requested a review from chvp March 2, 2020 12:26
const spanText: Text = document.createTextNode(I18n.t("js.annotation.were_hidden.first") + " ");
span.appendChild(spanText);

const link: HTMLAnchorElement = document.createElement("a");
const data: string = I18n.t(`js.annotation.were_hidden.second.${count > 1 ? "plural" : "single"}`).replace(/{count}/g, String(count));
const linkText: Text = document.createTextNode(data);
link.href = "#";
link.addEventListener("click", function (ev) {
ev.preventDefault();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the event handler for expanding all annotations? You should add this there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already attached here, giving the user a bit of leniency about where to click.

this.annotationsWereHidden.addEventListener("click", () => this.showAllButton.click());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want this? The whole point of a link is to make users know that it's clickable, so I don't think we need clickability outside of the link. @bmesuere Do you have an opinion on this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only make link clickable, it's what users expect

@@ -51,7 +51,7 @@ en:
hidden: Hide correct tests
annotations:
title: Annotations
show_all: Show annotations
show_all: Show all annotations
hide_all: Hide annotations
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hide_all: Hide annotations
hide_all: Hide all annotations

@@ -51,7 +51,7 @@ nl:
hidden: Verberg correcte tests
annotations:
title: Annotaties
show_all: Toon annotaties
show_all: Toon alle annotaties
hide_all: Verberg annotaties
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
hide_all: Verberg annotaties
hide_all: Verberg alle annotaties

@chvp chvp merged commit 146957c into develop Mar 11, 2020
@chvp chvp deleted the issue/1733 branch March 11, 2020 08:18
chvp added a commit that referenced this pull request Mar 11, 2020
Correct counting problem with hidden annotations
@bmesuere bmesuere added the bug Something isn't working label Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show X other annotations is incorrrect
3 participants