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: put current page at top of ClassName dropdown (was broken) #3004

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

sunnysideup
Copy link
Contributor

@sunnysideup sunnysideup commented Sep 13, 2024

Description

For the "Page Type" field in the settings tab (main) of a page, the current Page Type is supposed to be on top (see code changed). The code did not actually do that though and instead just placed the "last" entry in the list on top. That does not make any sense so I fixed it.

Manual testing steps

Open any SS website, go to the settings of a page and look at the list of Page Type options. You will see they are in alphabetical order, but the last one (e.g. the one that starts with last letter in the alphabet is listed first). The current page type is supposed to be listed first!

Issues

#3005

Also see:
#2209
#2208

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@sunnysideup sunnysideup changed the title FIX: put current page on top of ClassName dropdown (was broken) FIX: put current page at top of ClassName dropdown (was broken) Sep 13, 2024
@GuySartorelli
Copy link
Member

The "Issues" section is for you to link to an issue. This is made clear in the pull request template:

List all issues here that this pull request fixes/resolves.
If there is no issue already, create a new one! You must link your pull request to at least one issue.

Please create a GitHub issue if there isn't one already and link to it. If there's already an issue, please link to that.

@GuySartorelli
Copy link
Member

You've also put "[ N]" next to "This change is covered with tests (or tests aren't necessary for this change)"

Does this mean you think tests are needed, but haven't included them?
Please either include tests, or explain why tests aren't needed.

@sunnysideup
Copy link
Contributor Author

Does this mean you think tests are needed, but haven't included them?
Please either include tests, or explain why tests aren't needed.

Test are nice, but I dont have time for it and I dont think such a simple piece of code needs a test (famous last words), partially because it has not had a test so far, AFAIK.

@sunnysideup
Copy link
Contributor Author

In Terms of a test, I think it would be more valuable for a human to see that the UX feels good and works nicely. I was thinking that you could have:

-- MyPageType (current type) -- 
OtherPageType1
OtherPageType2

etc...
So that you can always see what the current one is.

@GuySartorelli
Copy link
Member

The point of unit tests is primarily to prevent regressions. This is a perfect example of something that was working at some point, but due to lack of unit tests it broke at some stage without anyone noticing.

To prevent this breaking again, it would be best to have a unit test.

@sunnysideup
Copy link
Contributor Author

What exactly would you test for? Would you test that it returns an array or that it returns a valid array? @GuySartorelli - I'd be curious if you had any ideas on what exactly to test for.

@sunnysideup
Copy link
Contributor Author

I have added a bunch of tests.

@michalkleiner
Copy link
Contributor

Just passing by, left a few minor comments. Thanks for taking the time to add the tests as well, @sunnysideup!

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

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

LGTM and works well locally.
Thank you for making this change.

Comment on lines +1362 to +1364
/**
* @return void
*/
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
/**
* @return void
*/

We don't need this typehint, but I won't delay merging just for this.

@GuySartorelli GuySartorelli merged commit 24bb95d into silverstripe:5 Sep 17, 2024
15 checks passed
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.

3 participants