How can we finish this in the foreseeable future?

Created on 29 September 2024, 4 months ago

Problem/Motivation

1. I don't like the current approach with dialogAdapter because dialog.js has always been an adapter itself and was written to roughly replicate the HTMLDialog implementation but with an adjustment for the jQuery dialog
https://git.drupalcode.org/project/drupal/-/blob/HEAD/core/misc/dialog/d...

2. I don't like the fact that instead of writing a modern library, we started by worrying about backward compatibility with a very outdated library first. This keeps us within the framework of an outdated API and forces us to write code as it was before. I think we should first write good code and then worry about its backward compatibility. We can easily not support something from the old library.

3. I don't like that the only way to test is Drupal. Yes, we are writing a library for Drupal. But if we imagine the number of options that we need to test, it becomes obvious that we need to be able to test all the options for using the dialog without Drupal, simply by having various objects with options.

Proposed resolution

1. Typescript.

This has already allowed me to fix several bugs in the current implementation and will allow us to avoid mistakes in the future. Most Drupal developers know PHP and types are also familiar to them. Frontend developers will also find it useful to work with strict types.

We take into account the types from the old dialog:
https://www.npmjs.com/package/@types/jqueryui
I also added types for Drupal directly here.
Later, we may be able to move this to this old PR
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/4687

At the moment the build compiles valid code for Drupal and all dialogs work as before.

2. Development environment. Vite in Library mode.

I added a test environment where we can create any number of dialog settings and test them in one place without Drupal.
See src/dev/tests.ts
I also added typescript compilation and a watch command to Vite. Subsequently, we can set up automatic testing and much more that a modern frontend provides.

3. Get rid of the redundant Adapter.
Add a library that will support (or not) old methods and options.

Feature request
Status

Active

Version

1.0

Component

Code

Created by

🇷🇸Serbia finnsky

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024