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

Wrap Dijit widgets required to move the UI away from directly depending on Dojo #7214

Closed

Conversation

ehuelsmann
Copy link
Member

@ehuelsmann ehuelsmann commented Feb 11, 2023

The purpose of this PR is to move parsing of the DOM away from Dojo: the browser can do it a lot more efficiently using Custom Web Components. These web components can instantiate Dojo widgets (for now) to create a consistent UI experience (which we can later swap for another type of custom element for a different look).

We make Dojo widgets out of standard elements in some places, such as the TABLE element which is converted to a lsmb/InvoiceLines widget. Support for this usage exists in custom web components using the is attribute.

There's a problem with Custom Built-in Web Components: Safari does not support Custom Web Elements for built-in elements. There is a solution to that problem: using a polyfill.

@ehuelsmann ehuelsmann changed the title Add radio buttons and checkboxes as custom elements Wrap Dijit widgets required to move the UI away from directly depending on Dojo Feb 12, 2023
@ehuelsmann ehuelsmann force-pushed the cleanup/more-webelements branch 2 times, most recently from 9ab7d5a to 46d9e3e Compare February 12, 2023 20:45
@ehuelsmann ehuelsmann force-pushed the cleanup/more-webelements branch from 46d9e3e to 5eaba06 Compare March 7, 2023 22:45
@ehuelsmann ehuelsmann force-pushed the cleanup/more-webelements branch from 5eaba06 to 397aaed Compare April 4, 2023 20:42
@ehuelsmann ehuelsmann force-pushed the cleanup/more-webelements branch from 397aaed to d30ee73 Compare April 16, 2023 08:33
@ehuelsmann
Copy link
Member Author

Testing showed that it's impossible to use the dojo parser in combination with dojo-based custom components: the browser renders the widgets, but the AMD parser does it again, leading to havoc. This means we can't partially move to the use of these widgets. We either need to go "all in" or forget about it.

I'm all for moving: it means that each element maintains its own state and registration with the Dojo widget registry, eliminating the need to sync destruction of Dojo widgets with Vue state. It also opens the possibility to start moving to a heavier (and smarter) web-UI as described above.

@ehuelsmann
Copy link
Member Author

@ylavoie do you have any comments as to my reasoning?

Note: my idea is that eventually, we use Vue to control the UI and we use web components for the layout. Thereby I mean: checkboxes, textboxes, date selectors, drop-downs etc will be custom components. The component adding/removing lines on the invoice will eventually be a Vue component.

@ehuelsmann ehuelsmann force-pushed the cleanup/more-webelements branch from d30ee73 to 10066d9 Compare July 8, 2023 06:26
/** @format */
/* eslint-disable class-methods-use-this */

import { LsmbDijit } from "@/elements/lsmb-dijit";

Check notice

Code scanning / CodeQL

Unused variable, import, function or class

Unused import LsmbDijit.

const Form = require("lsmb/Form");
const registry = require("dijit/registry");
const parser = require("dojo/parser");

Check notice

Code scanning / CodeQL

Unused variable, import, function or class

Unused variable parser.
@ehuelsmann ehuelsmann force-pushed the cleanup/more-webelements branch from fdaeeea to 7dbdfa3 Compare July 8, 2023 19:12
@ehuelsmann
Copy link
Member Author

ehuelsmann commented Oct 7, 2023

Additional findings while working on this PR showed that Dojo creates new nodes in the DOM tree, even if that would not be necessary (e.g. because the tag is only being "enhanced" with additional methods). This means it's impossible for custom tags to be a dojo widget at the same time: when passing the DOM node (this) to Dojo, it removes the node from the DOM and puts its own tag (a standard tag) in place.

For some widgets, the fact that they are replaced isn't much of an issue (input boxes, etc); others can be rewritten because they don't really use much of Dojo's widget functionality (Invoice, Reconciliation and friends), but others are hard to work around ('dijit/layout/BorderContainer', ContentPane and TabContainer).

@ehuelsmann
Copy link
Member Author

Based on the discussion and findings so far, is clear were not there yet... Closing for now.

@ehuelsmann ehuelsmann closed this Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant