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

Clear out the content container rather than deleting it #10036

Merged
merged 2 commits into from
Oct 21, 2020

Conversation

tristen
Copy link
Member

@tristen tristen commented Oct 15, 2020

Launch Checklist

This PR changes behavior in popup.js. Currently, when setDOMContent is called, it destroys the content container, creates a new one, and populates. This is undesirable under situations where you don't want to introduce a CSS file as a dependency to a plugin and wish to modify the content container using JavaScript.

Right now I'm calling this every time I want to add new data (which is happening on mouseover when queryRenderedFeatures returns a response):

const selector = popup.getElement().querySelector('.mapboxgl-popup-content');
selector.style.padding = '0'
Without modifications With modifications
Screen Shot 2020-10-15 at 5 15 15 PM Screen Shot 2020-10-15 at 5 15 40 PM

I would prefer to modify the DOM once and not have this be repeatedly called.

I'm a little nervous this constitutes a breaking change even though it's minor. Curious what y'all thoughts are.

  • briefly describe the changes in this PR
  • include before/after visuals or gifs if this PR includes visual changes
  • write tests for all new functionality
  • document any changes to public APIs
  • post benchmark scores
  • manually test the debug page
  • tagged @mapbox/map-design-team @mapbox/static-apis if this PR includes style spec API or visual changes
  • tagged @mapbox/gl-native if this PR includes shader changes or needs a native port
  • apply changelog label ('bug', 'feature', 'docs', etc) or use the label 'skip changelog'
  • add an entry inside this element for inclusion in the mapbox-gl-js changelog: <changelog>Clear out the popup content container instead of deleting it</changelog>

Copy link
Contributor

@ryanhamley ryanhamley left a comment

Choose a reason for hiding this comment

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

Looks good!

@tristen tristen merged commit 2311a03 into main Oct 21, 2020
@tristen tristen deleted the delete-popup-content-children branch October 21, 2020 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants