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

Fix dropdowns and logout #4056

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Fix dropdowns and logout #4056

wants to merge 5 commits into from

Conversation

Rieven
Copy link
Contributor

@Rieven Rieven commented Jan 30, 2025

Changes

  • Fixed double dropdown open due to inconsistency in templates.
  • Fixed Logout button. The logout was not working due to a GET request instead of POST
  • Correcting CSS for buttons and links with form wrapped or without.
  • Correcting width and positioning of dropdowns.

Issue link

#4055

Closes #4055

Demo

Screen.Recording.2025-01-30.at.14.08.24.mov

QA notes

you have to run yarn to test out these changes:
cd rocky
nvm use 18
yarn
yarn dev


Code Checklist

  • All the commits in this PR are properly PGP-signed and verified.
  • This PR only contains functionality relevant to the issue.
  • I have written unit tests for the changes or fixes I made.
  • I have checked the documentation and made changes where necessary.
  • I have performed a self-review of my code and refactored it to the best of my abilities.
  • Tickets have been created for newly discovered issues.
  • For any non-trivial functionality, I have added integration and/or end-to-end tests.
  • I have informed others of any required .env changes files if required and changed the .env-dist accordingly.
  • I have included comments in the code to elaborate on what is not self-evident from the code itself, including references to issues and discussions online, or implicit behavior of an interface.

Checklist for code reviewers:

Copy-paste the checklist from the docs/source/templates folder into your comment.


Checklist for QA:

Copy-paste the checklist from the docs/source/templates folder into your comment.

@Rieven Rieven self-assigned this Jan 30, 2025
@Rieven Rieven requested a review from a team as a code owner January 30, 2025 13:10
@@ -31,7 +26,11 @@
border: 1px solid var(--colors-grey-200);
background-color: var(--colors-white);
max-height: 90vh;
overflow-x: scroll;
Copy link
Contributor

Choose a reason for hiding this comment

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

This was added for a reason. (eg, very long lists of organizations)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but we do not need to scroll in the x direction

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm true, that should have been overflow-y
Odd that it seems to have worked anyway, probably because scroll is on by default..

Comment on lines -2 to -3
max-width: 50%;
width: auto;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure you need to remove all of these lines to make the clicking work again? It seems unlikely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There were a lot of inconsistencies when it comes to width, having the items in the dropdown to expand for a and buttons they must expand to full width and where the min width is the width of the max-content.

{{ lang.name_local.title }}
</button>
</a>
<button form="set-language" type="submit" name="language" value={{ language }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Still dont understand why our language switching is handled by a form, and not just a link.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is how it should be done according to the Django docs

Copy link
Contributor

Choose a reason for hiding this comment

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

I assume because we're using Django's set_language redirect view that handles this switch. According to the docs: The view expects to be called via the POST method, with a language parameter set in request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

POST requests are for State changes.
A switch to a different language is not a state change (or shoudn't be) as the used language is present in each url, and cannot rely on stateful magic to select the language anyway.
For example, what would be the state if you where to select English. And then go to an url with dutch listed as the language. Would that GET url magically do the same state change, or does the language not reply on state, but instead just rely on the language listed in the url?

<form id="set-language"
action="{% url "set_language" %}"
method="post"
class="inline">
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess the form could be class="hidden" as it contains no elements anyway?

Copy link
Contributor Author

@Rieven Rieven Jan 30, 2025

Choose a reason for hiding this comment

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

I moved this code together with the language selector button. It has 1 button in it that submits the value or we can create an input type hidden to set the value.

<div class="collapsing-element">
<div class="dropdown">
<button type="button"
aria-controls="user-profile"
Copy link
Contributor

Choose a reason for hiding this comment

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

We seem to have lost the data-open en data-close labels?

Copy link
Contributor Author

@Rieven Rieven Jan 30, 2025

Choose a reason for hiding this comment

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

Ahh, yes, I will add them again. This code is a bit old as we were waiting for the new Manon. I don't know if this is the case now, or I can just add it for the new styling of manon. I know that there were some differences in rocky why we use buttons. reference: https://minvws.github.io/nl-rdo-manon/components/collapsible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now I know why we choose the button styling. using styling of Manon we can only add text for data-open-label and data-close-label Here is an example:
image

The text will be added as dropdown text, but we use icons as well, the alternative was to use buttons instead so we can have more flexibility. But I think we can find a mid way between both. I think I can just add these labels and change text when it opens for screen readers.

Copy link
Contributor

Choose a reason for hiding this comment

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

@ppvg could you shine your light 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.

I'm not sure I know what the question is so I'd have to look into this.

I can say though that:

  1. The reason for Manon's dropdown to rely on data- attributes for the button label was for progressive enhancement, i.e. so that Manon can "inject" the button if (and only if) JS is available.
  2. I'm not convinced changing the label was a good idea, and it would probably be better to use the label only to identify (e.g. "profile menu") and use ARIA attributes to convey state (e.g. aria-controls + aria-expanded= true/false). We should probably revise Manon's dropdowns in a future version.

Copy link

@underdarknl
Copy link
Contributor

closes #3402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Overlapping dropdowns language and user settings
5 participants