TeselaGen / tg-oss

Teselagen Open Source modules
https://teselagen.github.io/tg-oss/
MIT License
37 stars 18 forks source link

OVE: annotationVisibility.featureTypesToHide not working in SimpleCircularOrLinearView #85

Closed manulera closed 2 weeks ago

manulera commented 2 weeks ago

Hi @tnrich,

I noticed that hiding features by type (or by id) does not work in SimpleCircularOrLinearView. I made a demo in the usual demo page:

https://ove-playground.netlify.app/

In the demo, I render both the normal editor and the SimpleCircularOrLinear one, see below. It only works in the main editor.

Full code example here: https://github.com/manulera/ove_playground

Happy to implement / fix if you point me to a starting point!

// Rendering code
    const nodeRef = React.useRef(null);
    React.useEffect(() => {
        const editorProps = {
            sequenceData: processedSequence,
            ...defaultMainEditorProps,
            annotationVisibility: {
                features: !hideAll,
                featureTypesToHide: { misc_feature: hideFeature },
            }
        };
        const editor = createVectorEditor(nodeRef.current, { editorName: 'mainEditor', height: '800' });
        editor.updateEditor(editorProps);
    }, [parsedSequence, hideFeature]);

    return (
        <div className="App">
            <SimpleCircularOrLinearView
                sequenceData={processedSequence}
                editorName="previewEditor"
                annotationVisibility={{
                    features: !hideAll,
                    featureTypesToHide: { misc_feature: hideFeature },
                }}
            ></SimpleCircularOrLinearView>
            <div ref={nodeRef} />
        </div>
    );
tnrich commented 2 weeks ago

@manulera unfortunately this is a somewhat complicated ask. I think it would be better to simply filter the features being passed into the SimpleCircularOrLinearView.

featureTypesToHide is being processed by a redux connected HOC called withEditorProps which is really meant to power a full blown seq editor. Trying to extract just that functionality from withEditorProps is non-trivial and also not necessarily what SimpleCircularOrLinearView was built for, hence the word Simple in the name.

You're welcome to hack on this yourself but might find it hard to come up with a clean solution. If you do, feel free to submit a PR. Closing for now though

manulera commented 2 weeks ago

simply filter the features being passed into the SimpleCircularOrLinearView.

Yes, that makes a lot of sense. Somehow did not think about it!

Thanks!