eeditiones / tei-publisher-components

Web components used by TEI Publisher and apps generated by it
https://cdn.tei-publisher.com/
GNU General Public License v3.0
18 stars 14 forks source link

toggle-feature and select-feature cause errors reloading the page #147

Open tuurma opened 1 year ago

tuurma commented 1 year ago

Selecting configuration with pb-toggle-feature or pb-select-feature adjusts the URL to include selectors=.... section which prevents the page from being reloaded correctly

Compare

https://teipublisher.com/exist/apps/tei-publisher/test/lelewel1.xml?view=page&norm=off&odd=lelewel

vs

https://teipublisher.com/exist/apps/tei-publisher/test/lelewel1.xml?view=page&norm=on&odd=lelewel&selectors=%5Bobject+Object%5D

line-o commented 1 year ago

I was able to reproduce the incorrect URL by clicking the "Normalised View" checkbox in the top toolbar.

line-o commented 1 year ago

I found the code that is responsible for adding the selectors to the URL. It is PbView.toggleFeature(ev).

registry.getState(this) will return the array of selectors among all other properties. These properties are then used in a call to registry.commit() which adds the selectors to the URL.

line-o commented 1 year ago

By simply removing the selectors from the properties before calling registry.commit() does keep the URL clean and the state can be toggled.

        // shield URL from selectors
        delete properties.selectors
line-o commented 1 year ago

Side note: Initial toggle states are not picked up properly in the client-side demo.

line-o commented 1 year ago

The selectors property is sometimes stored in state and sometimes only in channelState from what I gather.

line-o commented 1 year ago

related https://github.com/eeditiones/tei-publisher-components/issues/149