Urgent.News

What's breaking now, across thousands of outlets.

Tech

How I keep feedback pins on the right element when a website changes

When I built PinReview, a tool that lets clients click anywhere on a website and leave feedback, I thought the hard part would be screenshots. It wasn't. The hard part was making a pin still point at the right element after the page changes. A client pins a comment on a button. The next day a developer adds a banner above it, or opens the page on a phone instead of a laptop. Where should the pin…

When PinReview creator developed a tool for clients to leave feedback on specific elements of a website, the primary challenge was ensuring the feedback pin followed the element even as the page layout changed. Initially, the creator attempted to save the click's x, y coordinates, but this approach proved unreliable due to factors like screen size, scrolling, responsive design, and content changes above the target element.

Instead, the creator decided to store the element's unique identifier, such as its ID, test attributes, name, or aria-label. They built a ranked list of CSS selectors, starting with the most stable options like auto-generated IDs (rejecting those that appear generated) and CSS-in-JS classes (which vary between deployments). Test attributes were found to be the most stable anchors after real IDs.

To position the pin accurately, it is stored as a percentage of the element's size rather than the page, ensuring that its location remains consistent regardless of changes to the element's size across different devices. Each comment also includes a screenshot of the reviewer's view, along with the URL, viewport size, browser, OS, and any console errors, allowing developers to revisit the original context even if the live page undergoes significant changes.

However, the tool does face challenges with identical elements, such as multiple product cards sharing the same classes and lacking unique identifiers. In such cases, the pin may incorrectly target the wrong element if a new item is added. The creator suggests a possible solution of assigning unique identifiers to repeated elements or storing a small fingerprint of the element's text and tag, enabling the pin to indicate that it may have moved instead of confidently pointing at the wrong element.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

🔐 Use the AWS CLI Without Access Keys, and Prove a Policy Before You Attach It (Hands-on)

🎤 The interview question "How do you use the AWS CLI without an access key, and how do you know a policy works before you attach it?" The strong answer is two things you have actually run : sign the…

  • Use AWS CLI with temporary credentials, not access keys
  • Validate policies with AWS IAM Policy Simulator before attachment
  • Clean up resources after testing the least privileged policy

Nature Go

  • Nature Go app encourages screen-free outdoor exploration
  • AI verification layer ensures real outdoor discoveries
  • Open-source model adaptable for diverse communities

Why Is My Code Slow? Big-O Explained With Real Timings

Almost every developer knows Big-O. Many can even say what O(n²) means. But very few have watched the real difference happen on their own machine.

  • Nested loops method takes O(n²) time complexity, causing exponential growth in execution time
  • Set method uses O(n) time complexity, providing linear growth in performance
  • Experiment demonstrates importance of choosing efficient algorithms and data structures

More from Sunday 11 October →