Skip to content

Add css_id parameter to Viewable components#7617

Closed
philippjfr wants to merge 4 commits intomainfrom
css_ids
Closed

Add css_id parameter to Viewable components#7617
philippjfr wants to merge 4 commits intomainfrom
css_ids

Conversation

@philippjfr
Copy link
Copy Markdown
Member

@philippjfr philippjfr commented Jan 15, 2025

While we probably want to eventually expose this at the Bokeh level, adding an ID on the DOM nodes that correspond to Panel components is a useful way of referencing individual components for testing and when trying to look up a component. This PR implements this via tags, i.e. when an css_id is set this is added as an item in the tags property of the Model. On Document initialization on the frontend the css_id is then applied.

  • Add tests ensuring the id is added to all component types
  • Add tests ensuring the id is set on components added after initialization
  • Add documentation

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.75%. Comparing base (43761b8) to head (1e84dd5).
Report is 333 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7617      +/-   ##
==========================================
+ Coverage   81.83%   86.75%   +4.92%     
==========================================
  Files         341      341              
  Lines       51661    51688      +27     
==========================================
+ Hits        42275    44843    +2568     
+ Misses       9386     6845    -2541     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@maximlt
Copy link
Copy Markdown
Member

maximlt commented Jan 15, 2025

How about html_id?

@MarcSkovMadsen
Copy link
Copy Markdown
Collaborator

Or element_id?

@Coderambling
Copy link
Copy Markdown
Collaborator

Is it the case that CSS framework refer to this as "id"? In that case css_element_id might be the most appropriate.

I wonder if element_id might be confusing, or if, in future, some_other_thing_element_id might be a useful name, in which case element_id could become confusing.

Am I correcting in assuming the css element (with a unique id) would be available to all components (but not necessarily applied to all components)?

Would it be useful if the documentation contained code that shows how to list what components are using the CSS element? And what CSS elements a particular component uses?

@philippjfr philippjfr closed this Jul 21, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 4, 2025

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants