Skip to content

Conversation

@draunger
Copy link
Contributor

@draunger draunger commented Apr 27, 2025

description :

  • added the deletion of changeset comment

fixes :

#10957

@draunger draunger changed the title feat-deletion-in-changeset-comment feat-deletion-in-changeset-comment dropdown Apr 27, 2025
Copy link
Collaborator

@tordans tordans left a comment

Choose a reason for hiding this comment

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

A few thoughts I had when reading the code in Github.

osm.userChangesets(function (err, changesets) {
if (err) return;

var deleted = (JSON.parse(localStorage.getItem('deletedChangesetComments') || '[]')).map(s => s.trim().toLowerCase());
Copy link
Collaborator

Choose a reason for hiding this comment

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

This logic .map(s => s.trim().toLowerCase()); is duplicated in a lot of places. Do we really need it? We only ever compare the full string, to it should be OK to compare it as it. Otherwise we might want to extract it into a helper?

Another way would be to only store and compare hashes of those lines… but I don't think that is needed / has benefits.

Copy link
Member

Choose a reason for hiding this comment

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

I would even go as far as to store the changeset id of the to be ignored comments instead of the actual literal comment string itself. That would be more memory efficient and be the most stable implementation.

Copy link
Member

Choose a reason for hiding this comment

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

what also needs to be taken into account in the store-changeset-id approach is that in case that there exists more than one changeset with the to be ignored comment, all respective changeset ids need to be added to the list. but this does come with an implicit benefit: when the user at some later point manually enters a previously deleted comment, it will be again visible in the suggestions (until deleted again). When storing the comment itself, a user would not be able to undo an accidental deletion of a specific comment.

d3_select(this).text(d.value);
option.text(d.value);
}
// Only for comment combobox: add cross button, floated right, minimal style
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we somehow extract this into a separate file? I don't think it is ideal when this code block has to be read by every one who works on this component when it is really a separate component or feature.

Copy link
Member

Choose a reason for hiding this comment

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

yeah… at the very least we need to make this not hardcoded to a specific UI field: The logic should be reusable for other fields like the changeset source for example.

I could think of two ways to approach this:

  • leave the rendering code here, but introduce a new configuration method to enable "removable" entries for a specific combobox (uiCombobox(…).setRemovable(callback)). The callback function is called whenever an × is clicked on.
  • use the existing possibility to supply the display property on the to be rendered comments , and append the × and respective logic there.

As the logic is currently only needed for the changeset editor, maybe the second approach is more efficient…

let valueNorm = d.value.trim().toLowerCase();
if (!deleted.map(s => s.trim().toLowerCase()).includes(valueNorm)) {
deleted.push(d.value);
localStorage.setItem('deletedChangesetComments', JSON.stringify(deleted));
Copy link
Collaborator

Choose a reason for hiding this comment

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

How will this get reset? Like, when I click it 100 times, all those will be in the stack forever, right? Should we maybe allow for a max of 100 items and remove the last items? Like a max array size…

Copy link
Member

Choose a reason for hiding this comment

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

It should be safe to remove any stored entries that do not match any changeset that is currently returned by the OSM API anymore.

@tyrasd tyrasd linked an issue Apr 28, 2025 that may be closed by this pull request
@tyrasd tyrasd added the usability An issue with ease-of-use or design label Apr 28, 2025
if (klass === 'comment') {
option.append('button')
.attr('class', 'combobox-delete')
.attr('title', 'Delete this comment')
Copy link
Member

Choose a reason for hiding this comment

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

User facing texts should never be hardcoded to English. See https://github.com/openstreetmap/iD/wiki/How-to-Use-iD%27s-Localizer-Module for how to add and use translatable strings.

@tyrasd
Copy link
Member

tyrasd commented Jun 10, 2025

closing as stale

@tyrasd tyrasd closed this Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

usability An issue with ease-of-use or design

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add "delete" (×) button next to each changeset comment in dropdown

3 participants