mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-04 06:01:59 +08:00
Expand collapsed section when focusing a cell inside (#1797)
This commit is contained in:
parent
a7ec938416
commit
5e64d3de87
1 changed files with 17 additions and 11 deletions
|
@ -924,6 +924,16 @@ const Session = {
|
|||
this.focusedId = focusableId;
|
||||
|
||||
if (focusableId) {
|
||||
// If the element is inside collapsed section, expand that section
|
||||
if (!this.isSection(focusableId)) {
|
||||
const sectionId = this.getSectionIdByFocusableId(focusableId);
|
||||
|
||||
if (sectionId) {
|
||||
const section = this.getSectionById(sectionId);
|
||||
section.removeAttribute("data-js-collapsed");
|
||||
}
|
||||
}
|
||||
|
||||
const el = this.getFocusableEl(focusableId);
|
||||
|
||||
if (focusElement) {
|
||||
|
@ -993,9 +1003,10 @@ const Session = {
|
|||
toggleCollapseSection() {
|
||||
if (this.focusedId) {
|
||||
const sectionId = this.getSectionIdByFocusableId(this.focusedId);
|
||||
const section = this.getSectionById(sectionId);
|
||||
|
||||
if (section) {
|
||||
if (sectionId) {
|
||||
const section = this.getSectionById(sectionId);
|
||||
|
||||
if (section.hasAttribute("data-js-collapsed")) {
|
||||
section.removeAttribute("data-js-collapsed");
|
||||
} else {
|
||||
|
@ -1011,15 +1022,10 @@ const Session = {
|
|||
section.hasAttribute("data-js-collapsed")
|
||||
);
|
||||
|
||||
if (allCollapsed) {
|
||||
this.getSections().forEach((section) => {
|
||||
section.removeAttribute("data-js-collapsed");
|
||||
});
|
||||
} else {
|
||||
this.getSections().forEach((section) => {
|
||||
section.setAttribute("data-js-collapsed", "");
|
||||
});
|
||||
}
|
||||
this.getSections().forEach((section) => {
|
||||
section.toggleAttribute("data-js-collapsed", !allCollapsed);
|
||||
});
|
||||
|
||||
if (this.focusedId) {
|
||||
const focusedSectionId = this.getSectionIdByFocusableId(this.focusedId);
|
||||
|
||||
|
|
Loading…
Reference in a new issue