Skip to content

Set a max length for many inputs #5156

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

Conversation

kommunarr
Copy link
Collaborator

@kommunarr kommunarr commented May 22, 2024

Set a max length for many inputs

Pull Request Type

  • Feature Implementation

Related issue

#5150 (comment)

Description

There's just no need for that much information in a custom label, because beyond a certain point, we're already limiting the visible text.

Excluded are places where an unconstrained input is valid:

  • Top Nav search bar
  • SponsorBlock Settings
  • Proxy Settings
  • External Player Settings
  • Player Settings
  • Password Settings
  • General Settings -> Invidious Instance

Testing

  • Test that appropriate inputs are limited from continued text
  • (Optional) Test edge case behavior when a playlist title is already above the max # characters and the title is edited. Expected outcome: you can't add new characters, but you can remove them, and save at any length.

Desktop

  • OS: OpenSUSE
  • OS Version: TW

Additional context

The User Playlist desktop list view breaks for long enough titles and descriptions. We probably need code truncating those after x lines. The descriptions are shown in full on mobile view, so it's still useful for them to be able to be longer than that.

Excluded are playlist descriptions, which presumably deserve to have some leeway, and the password input, to prevent the edge case of a user being locked out if they had a longer one set (and also why not for this one).
@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label May 22, 2024
@FreeTubeBot FreeTubeBot enabled auto-merge (squash) May 22, 2024 14:16
@absidue
Copy link
Member

absidue commented May 22, 2024

Please make the max length opt-in, that means the default value is null and then you pass in the limit in the few places it is needed, making it opt-out is going to cause more problems than it will solve. For example you currently set a 100 character limit on the search bar, with the reasoning that it makes the search query limit code obsolete, however that will break the second use of the search bar: handling URLs. The URLs can easily go over 100 characters, especially if they come from a tor Invidious instance, see this comment for more information: #4288 (comment)

@absidue absidue added PR: changes requested and removed PR: waiting for review For PRs that are complete, tested, and ready for review labels May 22, 2024
@kommunarr
Copy link
Collaborator Author

Thanks for this context @absidue, I wasn't aware of that. Will update.

@kommunarr
Copy link
Collaborator Author

Updated now to remove the constraints from places where it would restrict valid inputs. Kept the default value the same so we don't have to have a magic number, or a constant we'd have to import into each file.

@PikachuEXE
Copy link
Collaborator

Please make the max length opt-in, that means the default value is null and then you pass in the limit in the few places it is needed, making it opt-out is going to cause more problems than it will solve.

I don't think this is solved
And also now I have no idea what to test (coz the diff doesn't show the list of inputs

@kommunarr
Copy link
Collaborator Author

I don't think this is solved

See answer:

Kept the default value the same so we don't have to have a magic number, or a constant we'd have to import into each file.

And also now I have no idea what to test (coz the diff doesn't show the list of inputs

Thanks, just updated the OP with the list of non-affected inputs.

Copy link
Collaborator

@PikachuEXE PikachuEXE left a comment

Choose a reason for hiding this comment

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

  • Playlist Name should be 255 at least (or unlimited)
  • Playlist Description should be 255 at least (or unlimited)
  • Proxy Port Number should be 5

Also in #5150 (comment) I simply means limiting the displayed value not input value

@kommunarr kommunarr requested a review from PikachuEXE May 23, 2024 12:03
PikachuEXE
PikachuEXE previously approved these changes May 24, 2024
@kommunarr kommunarr added PR: waiting for review For PRs that are complete, tested, and ready for review and removed PR: changes requested labels May 26, 2024
@absidue
Copy link
Member

absidue commented May 27, 2024

I still think it would be better to get rid of the implicit limit of 100 and instead set explicit limits where they are actually required. Your argument was that we would need a magic constant imported into multiple files, but I would argue that we don't need a constant at all, just write the number where it is needed. Secondly the current situation is worse, because it's still a magic number, but you don't see it at the call/usage site, so you won't even know it exists unless you stumble upon it in testing or remember to look at the ft-input component. It also means we won't have to override it with null in so many places anymore.

@absidue
Copy link
Member

absidue commented May 27, 2024

Other than that it looks good now, thank you for doing the changes.

@kommunarr kommunarr changed the title Set a max length of 100 for most inputs Set a max length for many inputs May 28, 2024
@FreeTubeBot FreeTubeBot merged commit 32a08d1 into FreeTubeApp:development May 29, 2024
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label May 29, 2024
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.

5 participants