Skip to content

Allow to star and unstar stored segment#23771

Merged
tzi merged 17 commits into5.x-devfrom
ux-326
Dec 12, 2025
Merged

Allow to star and unstar stored segment#23771
tzi merged 17 commits into5.x-devfrom
ux-326

Conversation

@tzi
Copy link
Copy Markdown
Contributor

@tzi tzi commented Nov 12, 2025

Description

New “Star” Feature: each segment can be "starred" by clicking on a star icon.
Starred segments are highlighted at the top of the list.

What happen when a segment star is clicked :

  • Move the segment immediately at the top of the list
  • The Star icon is filled in
  • A API called is made to store this change

Screenshots

before / after
before after
tooltips
tooltip unstarred tooltip starred
Screenshot 2025-11-18 at 18 25 24 Screenshot 2025-11-18 at 18 25 37
Animation
star unstar error
star-star star-unstar star-error

Checklist

  • [NA] I have understood, reviewed, and tested all AI outputs before use
  • [NA] All AI instructions respect security, IP, and privacy rules

Review

@tzi tzi added the Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. label Nov 12, 2025
@tzi tzi changed the title Allow to start/unstar stored segment Allow to star and unstar stored segment Nov 14, 2025
@tzi tzi force-pushed the ux-326 branch 10 times, most recently from 24a8707 to cb064c5 Compare November 17, 2025 17:41
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ The new tests changed the visible focused element on this screenshot.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ The starred segment comes at the top of the list

Comment on lines +898 to +900
self.target.find('[title]').each(function () {
addTooltip(this, this.getAttribute('title'));
});
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ Fix tooltip for all actions in the SegmentList

Comment on lines +236 to +237
display: flex;
flex-direction: column;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ Use flexbox to be able to reorder starred segment easily.

Comment on lines +255 to +257
.segmentationContainer .submenu ul li[data-idsegment=""] {
order: 0;
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ℹ️ First line is always "All visitors"

@tzi tzi force-pushed the ux-326 branch 2 times, most recently from d004753 to 5c02c19 Compare November 17, 2025 23:55
@tzi tzi marked this pull request as ready for review November 18, 2025 01:03
@tzi tzi added Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc. c: Design / UI For issues that impact Matomo's user interface or the design overall. Needs Review c: Segments Segmentation and Segment editor related improvements and fixes. and removed Pull Request WIP Indicates the current pull request is still work in progress and not ready yet for a review. c: Design / UI For issues that impact Matomo's user interface or the design overall. labels Nov 18, 2025
@tzi tzi requested a review from a team November 18, 2025 01:03
Comment thread plugins/SegmentEditor/javascripts/Segmentation.js Outdated
Comment thread plugins/SegmentEditor/javascripts/Segmentation.js
Comment thread plugins/SegmentEditor/javascripts/Segmentation.js
Comment thread plugins/SegmentEditor/API.php Outdated
Comment thread plugins/SegmentEditor/API.php Outdated
@tzi tzi force-pushed the ux-326 branch 5 times, most recently from 8172f5b to bac2467 Compare December 9, 2025 03:15
var comparisonService = window.CoreHome.ComparisonsStoreInstance;
comparisonService.addSegmentComparison({
segment: $(e.target).closest('li').data('definition'),
const $button = $(this);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Small issue, but is there a reason you are using $button instead of button?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you mean the name of the variable?
I try to prefix the variable that are a jQuery element with $, I think I’ve seen this on the repository already. Because a button and a $button will not have the same API. So I know if I should write $button.getAttribute('data-state') or $button.attr('data-state').

const starTitleAttribute = 'title="' + getStarSegmentTitle(segment, canEdit) + '"';
listHtml += '' +
'<button data-star class="starSegment" '+ starTitleAttribute + ' ' + disabledAttribute + '>️' +
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24">' +
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn't we try to avoid inline svg's in general for the sake of re-usability and easy replaceability?
I understood that we can't use a font icon, due to the animation. But would that be possible through a background image maybe? That way we could handle that with a CSS class only, which would allow themes to overwrite it more easily 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I choose to not use a background image here, since we will not be able to change it’s color easily.
Otherwise we could a colored svg and make it black by default with a filter 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Discuss directly. It could be done in a follow up PR 👍

@tzi tzi dismissed stale reviews from michalkleiner and sgiehl December 12, 2025 11:20

✅ Done!

@tzi tzi merged commit dd29cb2 into 5.x-dev Dec 12, 2025
88 of 92 checks passed
@tzi tzi deleted the ux-326 branch December 12, 2025 11:28
@sgiehl sgiehl added this to the 5.7.0 milestone Jan 13, 2026
@sgiehl sgiehl linked an issue Mar 17, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: Segments Segmentation and Segment editor related improvements and fixes. Enhancement For new feature suggestions that enhance Matomo's capabilities or add a new report, new API etc.

Development

Successfully merging this pull request may close these issues.

New Segments Page: Combined Reporting and Management

6 participants