Allow selecting client-side or server-side trimming

Created on 17 October 2024, 5 months ago

Problem/Motivation

I love smart trim and I'm using it since Drupal 7. Now we had a case, where we didn't want to trim the field server-side, but client-side, so that clicking the more-link makes the text appear.

That's especially relevant if you have contents that should show up short on mobile, but be expandable directly without reload.

I think the options are very very similar and it would be super cool to have a switch in the formatter to just choose between Client-side (JS) and Server-side (PHP) trimming.

https://www.drupal.org/project/expand_collapse_formatter is the alternative for the JS part, but I think smart_trim could do it better and you'd not need different modules and different configuration, if you can just have the switch and the power of smart_trim! :)

What do you think?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

2.1

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Anybody
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    @maintainers: Would be great to get some feedback, if you understand and like the idea in general and if it's okay to put it into the main module as a setting within the formatter or if it needs to be a submodule!

  • 🇩🇪Germany lrwebks Porta Westfalica
  • Merge request !102Resolve #3481507 "Allow selecting client side" → (Open) created by lrwebks
  • Pipeline finished with Failed
    4 months ago
    Total: 208s
    #337457
  • Pipeline finished with Failed
    3 months ago
    Total: 204s
    #341986
  • Pipeline finished with Failed
    3 months ago
    Total: 386s
    #342066
  • Pipeline finished with Failed
    3 months ago
    Total: 218s
    #342169
  • Pipeline finished with Failed
    3 months ago
    Total: 223s
    #342181
  • Pipeline finished with Failed
    3 months ago
    Total: 203s
    #344464
  • Pipeline finished with Failed
    3 months ago
    Total: 781s
    #344595
  • Pipeline finished with Failed
    3 months ago
    Total: 226s
    #349143
  • Pipeline finished with Failed
    3 months ago
    Total: 267s
    #349169
  • Pipeline finished with Failed
    3 months ago
    Total: 266s
    #349196
  • Pipeline finished with Failed
    3 months ago
    Total: 203s
    #349234
  • Pipeline finished with Failed
    3 months ago
    Total: 201s
    #349255
  • Pipeline finished with Failed
    3 months ago
    Total: 218s
    #349306
  • Pipeline finished with Failed
    3 months ago
    Total: 331s
    #349389
  • Pipeline finished with Canceled
    3 months ago
    Total: 73s
    #349392
  • Pipeline finished with Failed
    3 months ago
    Total: 233s
    #349393
  • Pipeline finished with Failed
    3 months ago
    Total: 223s
    #350658
  • Pipeline finished with Failed
    3 months ago
    Total: 230s
    #363154
  • Pipeline finished with Failed
    3 months ago
    Total: 204s
    #363170
  • Pipeline finished with Failed
    3 months ago
    Total: 325s
    #369914
  • Pipeline finished with Failed
    3 months ago
    Total: 297s
    #370971
  • Pipeline finished with Failed
    3 months ago
    Total: 235s
    #371023
  • Assigned to lrwebks
  • Status changed to Needs review 3 months ago
  • 🇩🇪Germany lrwebks Porta Westfalica

    The base functionality and test coverage is there now, PHPUnit seems to fail due to an unrelated test from a different commit.

  • 🇩🇪Germany lrwebks Porta Westfalica

    Okay, perhaps the pipeline failure isn't that unrelated, I will take a look.

  • Pipeline finished with Failed
    3 months ago
    Total: 210s
    #371033
  • Pipeline finished with Failed
    3 months ago
    Total: 201s
    #371052
  • 🇩🇪Germany lrwebks Porta Westfalica

    Pipeline fixed!

  • Pipeline finished with Failed
    3 months ago
    Total: 209s
    #371054
  • Pipeline finished with Canceled
    3 months ago
    Total: 77s
    #371064
  • Pipeline finished with Failed
    3 months ago
    Total: 205s
    #371066
  • 🇩🇪Germany Anybody Porta Westfalica

    PHPStan is failing:

     ------ ---------------------------------------------------------------------------------------------- 
      Line   modules/smart_trim_client_side/tests/src/FunctionalJavascript/SmartTrimClientSideJSTest.php   
     ------ ---------------------------------------------------------------------------------------------- 
      21     PHPDoc type array of property                                                                 
             Drupal\Tests\smart_trim_client_side\FunctionalJavascript\SmartTrimClientSideJSTest::$modules  
             is not covariant with PHPDoc type array<string> of overridden                                 
             property Drupal\Tests\BrowserTestBase::$modules.                                              
    
  • First commit to issue fork.
  • Pipeline finished with Failed
    about 1 month ago
    Total: 319s
    #407353
  • Pipeline finished with Failed
    about 1 month ago
    Total: 213s
    #407361
  • Pipeline finished with Failed
    about 1 month ago
    Total: 260s
    #407389
  • 🇩🇪Germany Grevil

    Did a few adjustments and commented them for easier review. 1 Question is still open.

  • 🇩🇪Germany Grevil

    Last phpstan issue is unrelated.

  • 🇩🇪Germany Anybody Porta Westfalica

    @Grevil & @LRWebks: Could you please ensure all fixes here are also reported upstream (if the code was copied)? Please open a MR for that in a separate issue, if it has the same bugs.

    Thank you!

  • 🇩🇪Germany Grevil

    @Grevil & @LRWebks: Could you please ensure all fixes here are also reported upstream (if the code was copied)? Please open a MR for that in a separate issue, if it has the same bugs.

    The only upstream bug (missing token->replace variable initialization) IS fixed here. That's why I asked whether this is not too unrelated or not.

  • 🇩🇪Germany Anybody Porta Westfalica

    Okay I think separate issues should be opened for these upstream fixes. Quite self-explaining ones. So we have the discussion elsewhere.

  • 🇩🇪Germany Grevil

    Alright. Let's remove any unrelated changes and solve them inside an follow-up issue.

  • Pipeline finished with Failed
    about 1 month ago
    Total: 220s
    #408026
  • 🇩🇪Germany Grevil

    Alright, all done. LGTM!

    I will create follow-up issues for the other issues found.

  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    Great work guys, I'm so happy to see this soon. Wonderful addition to this wonderful and super useful module. I'm sure it will be widely used :)

  • Pipeline finished with Failed
    about 1 month ago
    Total: 249s
    #408037
Production build 0.71.5 2024