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

Add hide/show for limitList #9228

Merged
merged 26 commits into from
Nov 15, 2023
Merged

Conversation

cheesegrits
Copy link
Contributor

  • Changes have been thoroughly tested to not break existing functionality.
  • New functionality has been documented or existing documentation has been updated to reflect changes.
  • Visual changes are explained in the PR description using a screenshot/recording of before and after.

As requested by my users ... when using limitList() for listWithLineBreaks() in a TextColumn, replaces "and X more" text with "show X more" clickable text which reveals the additional values, and a "show X less" to hide them again.

Lmk if you want this behavior but would would prefer this behavior to be optional, perhaps with a named argument like limitList(5, hideShow: true).

2023-10-20_21-02-08.mp4

@danharrin danharrin added the bug Something isn't working label Oct 21, 2023
@danharrin danharrin added this to the v3 milestone Oct 21, 2023
@danharrin
Copy link
Member

This is good default behaviour, please also replicate it for TextEntry if that is appropriate

@danharrin danharrin marked this pull request as draft October 21, 2023 12:45
@zepfietje
Copy link
Member

Nice one, Hugh!
We should probably use the Filament link component for the button.

@cheesegrits
Copy link
Contributor Author

cheesegrits commented Oct 22, 2023

Nice one, Hugh! We should probably use the Filament link component for the button.

@zepfietje weirdly, if I switch the div to an x-filament::link, it destroys the list formatting. Any ideas?

EDIT - nevermind, if I use tag="button" it renders properly.

2023-10-21_20-46-28.mp4

@zepfietje
Copy link
Member

Yeah the link defaults to be a real link, so it needs the tag="button" attribute.
Should the color be primary or gray by the way? What do you think?

@danharrin
Copy link
Member

I think it should be gray

@zepfietje
Copy link
Member

Yeah I prefer that as well.

@zepfietje
Copy link
Member

I've updated the link color to gray for all instances in this PR.

@cheesegrits
Copy link
Contributor Author

OK, changed showLimited to isLimited in both table and infolist. Tweaked docs for infolist limitList() to match table.

Tested the Infolist stuff in the demo app.

I think that's everything?

2023-10-23_15-48-57.mp4

@zepfietje
Copy link
Member

Not sure if we need that x-transition. I think it looks snappier without it.

@cheesegrits
Copy link
Contributor Author

Not sure if we need that x-transition. I think it looks snappier without it.

@zepfietje hmm, I actually don't like it without, it's TOO snappy, especially if you have a lot of hidden items, and suddenly the everything just snaps off the bottom of the page. That's why I added it in the first place. But you are The Man, so tell me to remove it and I will. But at least test it with 50+ hidden items.

@zepfietje
Copy link
Member

Yeah I do understand your reasoning, @cheesegrits.
To be honest though, when I watched your screen recording, I thought it was a little janky, until I found it was actually an x-transition on purpose. 😅
I don't think the default scale animation works well in this case.
Also, I've never really seen this sort of thing animated, have you?

Comment on lines 6 to 7
'less_list_items' => 'Show :count less',
'more_list_items' => 'Show :count more',
Copy link
Member

@zepfietje zepfietje Oct 26, 2023

Choose a reason for hiding this comment

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

I think we should/could add this functionality to checkbox lists as well.
I'm mentioning this now since that'd make it easier to extract the translations instead of doing that later.
Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Checkbox lists don't have limits at the moment, and I don't think this needs transferring yet

>
{{ trans_choice('filament-tables::table.columns.text.more_list_items', $limitedArrayStateCount) }}
<x-filament::link
Copy link
Member

Choose a reason for hiding this comment

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

I feel like adding an icon (e.g. + or -) would make it more obvious that the link is a link after a long list of text. Not too sure yet though. What do you think?

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'll try it and see.

Copy link
Member

Choose a reason for hiding this comment

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

The font weight is already enough IMO, as well as the underline on hover. It is pretty clear that it's not just another list item.

@@ -193,8 +203,24 @@ class="cursor-pointer max-w-max"
@if ($limitedArrayStateCount = count($limitedArrayState ?? []))
<{{ $isListWithLineBreaks ? 'li' : 'div' }}
class="text-sm text-gray-500 dark:text-gray-400"
x-on:click.prevent="isLimited = ! isLimited"
Copy link
Member

Choose a reason for hiding this comment

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

We don't need these attributes on this wrapper anymore, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which attributes? The classes?

Copy link
Member

Choose a reason for hiding this comment

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

And the click handler. I guess these changes are from before we moved to using links?

Copy link
Member

Choose a reason for hiding this comment

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

Done

@danharrin danharrin added enhancement New feature or request and removed bug Something isn't working labels Oct 27, 2023
@danharrin danharrin modified the milestones: v3, v3.1 Oct 31, 2023
@danharrin danharrin changed the base branch from 3.x to 3.1 November 15, 2023 10:22
@danharrin danharrin marked this pull request as ready for review November 15, 2023 10:58
@danharrin
Copy link
Member

Decided this should be opt in, as people with huge limited lists could experience performance issues with the extra DOM elements

@danharrin danharrin merged commit 21fc6bf into filamentphp:3.1 Nov 15, 2023
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants