Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 5, 2025. It is now read-only.
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Editing a file removes theselected class from the file in the filetree #169

Closed
@tomoam

Description

@tomoam

Describe the problem

When you edit a file in the editor,selected class is removed from the file in the filetree (only happens on first edit).

selected_class_is_removed.2.mov

This is caused by comparingfile with$selected (i.e., these may refer to different objects with the same contents).

<divclass="row"class:selected={file===$selected}>

When you open a tutorial page, deep copy ofstub(file) is created...

/**
*@param{import('$lib/types').FileStub}stub
*/
functioncreate_file(stub) {
// deep-copy stub so we can mutate it and not create a memory leak
stub=JSON.parse(JSON.stringify(stub));

...then, if you edit a file,change event will be dispatched, andfile will be updated to deep copy of the one.

if (notify) {
stub.contents= contents;
dispatch('change', stub);
}

<Editor
stubs={$files}
selected={$selected}
read_only={$mobile}
on:change={update_stub}
/>

/**
*@param{CustomEvent<import('$lib/types').FileStub>}event
*/
functionupdate_stub(event) {
conststub=event.detail;
constindex=$files.findIndex((s)=>s.name===stub.name);
$files[index]= stub;
adapter?.update([stub]).then((reload)=> {
if (reload) {
schedule_iframe_reload();
}
});
update_complete_states([stub]);
}

Describe the proposed solution

Comparing with the respectivename property instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp