LearnNewsExamplesServices
Frontmatter
id5758
titleRemove main.addon.Browser
stateClosed
labels
enhancement
assignees[]
createdAtAug 15, 2024, 12:41 AM
updatedAtAug 15, 2024, 2:05 AM
githubUrlhttps://github.com/neomjs/neo/issues/5758
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtAug 15, 2024, 2:05 AM

Remove main.addon.Browser

Closed v8.1.0 enhancement
tobiu
tobiu commented on Aug 15, 2024, 12:41 AM

@Dinkh @rwaters: https://github.com/neomjs/neo/blob/dev/src/main/addon/Browser.mjs We should really stick to feature detection and not use regex to try determine a device type, which is not needed. The regex contains very outdated device types, but this is not the point.

Counter example:

    // worker.Manager
    detectFeatures() {
        let me = this;

        NeoConfig.hasMouseEvents = matchMedia('(pointer:fine)').matches;
        NeoConfig.hasTouchEvents = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0);

        if (window.Worker) {
            me.webWorkersEnabled = true
        } else {
            throw new Error('Your browser does not support Web Workers')
        }

        if (window.SharedWorker) {
            me.sharedWorkersEnabled = true
        }
    }

    // main.addon.DragDrop
        if (Neo.config.hasMouseEvents) {
            imports.push(import('../draggable/sensor/Mouse.mjs'))
        }

        if (Neo.config.hasTouchEvents) {
            imports.push(import('../draggable/sensor/Touch.mjs'))
        }

What could be important for styling (like the ContentBoxes inside the Portal App) is the info, if there is a mouse or not. So adding a new CSS rule to the doc body like neo-no-mouse should be fine.

For styling, only the sizes matter (responsive breakpoints).

If you want to get the user agent info for a specific use case, you can already easily do it:

Neo.Main.getByPath({path: 'navigator.userAgent'}).then(userAgent => {});
tobiu added the enhancement label on Aug 15, 2024, 12:41 AM
rwaters
rwaters Aug 15, 2024, 12:47 AM

Agreed that feature detection & media queries over browser detection are the way to go. Provides much more future proof code that does not need to be continually maintained as browsers evolve.

rwaters closed this issue on Aug 15, 2024, 12:47 AM
rwaters reopened this issue on Aug 15, 2024, 12:47 AM
tobiu referenced in commit 1e0077d - "reverted using the browser addon inside the portal app #5758" on Aug 15, 2024, 1:48 AM
tobiu referenced in commit aa0136a - "#5758 Portal.view.home.ContentBox: using the new no-mouse rule" on Aug 15, 2024, 1:55 AM
tobiu referenced in commit 2d10a9b - "#5758 Portal.view.home.ContentBox: restoring the lost formatting" on Aug 15, 2024, 2:04 AM
tobiu referenced in commit ac4de06 - "Remove main.addon.Browser #5758" on Aug 15, 2024, 2:05 AM
tobiu closed this issue on Aug 15, 2024, 2:05 AM