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

[Feature Request]: Allow teal to start with the filter panel collapsed #1220

Open
3 tasks done
chlebowa opened this issue May 16, 2024 · 9 comments
Open
3 tasks done
Assignees
Labels
blocked core enhancement New feature or request

Comments

@chlebowa
Copy link
Contributor

chlebowa commented May 16, 2024

Blocked by #669

Feature description

The filter panel can be toggled but is always displayed on app start. Please allow for the application to start with the filter panel collapsed.

Current start screen:
image

Desired start screen:
image

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.
@chlebowa chlebowa added the enhancement New feature or request label May 16, 2024
@donyunardi
Copy link
Contributor

We could add optional argument to teal_slices() to hide the filter panel when app runs.

@chlebowa
Copy link
Contributor Author

Sounds good.
Bear in mind, if initial expanding/collapsing the filter panel were decided by an attribute of the teal_slices object passed to init, it would be carried over with snapshots and bookmarks, which means the collapse state of the filter panel is not bookmarkable unless handled specifically.

@gogonzo
Copy link
Contributor

gogonzo commented May 23, 2024

Arbitral javascript doesn't help?

Theoretically calling hideSidebar() in js should do the trick.

We could add optional argument to teal_slices() to hide the filter panel when app runs.

Sidebar in which filter-panel is included shouldn't be controlled by filter panel. If we add more items to this sidebar then it would be weird if teal_slices have a control over sidebar. Should be either hidden by default or shown by default.

@chlebowa
Copy link
Contributor Author

Arbitral javascript doesn't help?

Theoretically calling hideSidebar() in js should do the trick.

Oddly, hideSidebar alone does not, more code is needed. Maybe it's a peculiarity of the context.

Sidebar in which filter-panel is included shouldn't be controlled by filter panel. If we add more items to this sidebar then it would be weird if teal_slices have a control over sidebar. Should be either hidden by default or shown by default.

How about teal::teal_slices?

@gogonzo
Copy link
Contributor

gogonzo commented May 24, 2024

How about teal::teal_slices

No, we are planning to include more items to the sidebar. teal_slices can't control visibility of the sidebar where teal_transform_module will be included.

Oddly, hideSidebar alone does not, more code is needed

How did you provide js code to the app?

I suspect this could be a problem of an initialization order. "sidebar" is created in a reactive context (insertUI) so any js call on init won't help. I guess #669 would solve the root of problem. Question is how can you provide jscode to the app?

@chlebowa
Copy link
Contributor Author

I suspect this could be a problem of an initialization order. "sidebar" is created in a reactive context (insertUI) so any js call on init won't help. I guess #669 would solve the root of problem.

I was afraid of that.

How did you provide js code to the app?


data <- teal_data() |> within({
  iris <- iris
  mtcars <- mtcars
})
modules <- example_module()

app <- init(data, modules, header = tags$script('hideSidebar()'))

runApp(app)

This didn't do the job. I tried with ui_teal_with_splash as well but that didn't work either.

The working code is injected straight into module_teal, using very poor practices.

@chlebowa
Copy link
Contributor Author

Just to be clear, this will not be done before #669, sorrect?

@chlebowa
Copy link
Contributor Author

Update: I was able to solve the issue in my very specific use case of running a teal app embedded but it cannot be generalized to a standalone app.

@chlebowa
Copy link
Contributor Author

Update: this script will hide the filter panel on start of a normal, standalone teal app:

const observer = new MutationObserver(function() {
  if (document.getElementsByClassName("teal_secondary_col").length) {
    toggleFilterPanel();
    observer.disconnect();
  }
});

observer.observe(
  document,
  {
    subtree: true,
    childList: true
  }
);

@gogonzo gogonzo mentioned this issue Jul 2, 2024
63 tasks
@gogonzo gogonzo self-assigned this Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked core enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants