Skip to content

fix: hide actions with authorization feedback when denial has no message#19792

Merged
danharrin merged 5 commits intofilamentphp:4.xfrom
intrepidws:policy-response-hidden-action
May 7, 2026
Merged

fix: hide actions with authorization feedback when denial has no message#19792
danharrin merged 5 commits intofilamentphp:4.xfrom
intrepidws:policy-response-hidden-action

Conversation

@intrepidws
Copy link
Copy Markdown
Contributor

Description

Currently authorizationTooltip() and authorizationNotification() always reveal a denied action, even when the policy returned a bare false. This can be lead to undesirable UX. For instance, simply showing a user a delete action (even in a disabled state) can lead to them questioning why they don't have that ability. While responses are helpful, it's sometimes preferrable to entirely hide the action.

This PR adds two new "or hidden" variants that give the message-bearing path the same UX as before, but fall back to hiding the action otherwise.

  • authorizationTooltipOrHidden() - disables the action with a tooltip when the deny response has a message; hides the action otherwise.
  • authorizationNotificationOrHidden() - keeps the action clickable and shows a notification when the deny response has a message; hides the action otherwise.

These variants are meant for scenarios where there is nothing useful to tell the user or it is desirable to entirely hide the existence of the action from the user:

Visual changes

When using either of these two new methods, the user will no longer see the action in scenarios where a message is not returned from the policy.

There are no changes (visual or otherwise) for current methods authorizationTooltip() and authorizationNotification.

Functional changes

  • Code style has been fixed by running the composer cs command.
  • Changes have been tested to not break existing functionality.
  • Documentation is up-to-date.

@github-project-automation github-project-automation Bot moved this to Todo in Roadmap Apr 29, 2026
@danharrin danharrin added enhancement New feature or request pending review labels Apr 30, 2026
@danharrin danharrin added this to the v4 milestone Apr 30, 2026
Copy link
Copy Markdown
Member

@danharrin danharrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In your opinion, should this just be default behaviour rather than opt-in?

@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Roadmap May 2, 2026
@intrepidws
Copy link
Copy Markdown
Contributor Author

@danharrin Yes, absolutely. But I figured that could be construed as a breaking change of sorts?

@danharrin
Copy link
Copy Markdown
Member

Potentially, but I don't think its necessarily expected behaviour that the button should be visible and disabled either in this case. The method is an opt-in feature that is meant to be used with response messages. When response messages aren't being used, I think we might have some flexibility to fix the behaviour.

@intrepidws
Copy link
Copy Markdown
Contributor Author

That's a fair point. Whatever you think makes sense here but I would agree that this seems like a smart default. Let me know if you want me to do anything.

@danharrin
Copy link
Copy Markdown
Member

Yeah, lets make it the default behaviour instead of introducing a config option please

@danharrin danharrin added bug Something isn't working pending changes and removed enhancement New feature or request pending review labels May 2, 2026
@intrepidws
Copy link
Copy Markdown
Contributor Author

@danharrin The changes have been made as requested.

@danharrin danharrin changed the title Add "or hidden" mode for action auth tooltips and notifications fix: hide actions with authorization feedback when denial has no message May 7, 2026
Moves the authorization feedback test cases from a standalone
AuthorizationFeedbackTest.php into a `describe('authorization', ...)`
block in ActionTest.php, alongside related Action behaviour tests.
Adds four baseline tests for the wider authorization concern (default
visibility, `authorize(false)` without feedback methods, `Response`
acceptance, and `authorizationMessage()` chaining), since no prior
tests covered any of `CanBeAuthorized`.
@danharrin danharrin merged commit 2f10baa into filamentphp:4.x May 7, 2026
23 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Roadmap May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants