Skip to content

FB9052637: NSStatusItem position is not perserved when using .isVisible #200

Open
@sindresorhus

Description

  • Date: 2021-03-24
  • Resolution: Open
  • Area: AppKit
  • OS: macOS 11.2.3
  • Type: Incorrect/Unexpected Behavior

Description

The docs for NSStatusItem#isVisible says:

The status item’s visiblity persists and restores automatically based on the value of autosaveName.

This however does not work. If you move the status bar item in the menu bar with Command+drag, then set .isVisible = false and then later .isVisible = true, the status bar item appears at the far left of the status bar instead of its previous position. This is clearly not the intended behavior.

Steps to reproduce:

  • Open the attached test case project.
  • Build and run.
  • Command-drag the menu bar item to the far right of the menu bar.
  • Click it to hide it.
  • Wait 2 seconds.
  • The menu bar item will reappear, but it will have lost its position.

The only way to ensure the position is preserved is to relaunch the app right after changing the position in the menu bar, which is not ideal.

Files

Test case project.zip

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions