Skip to content

fix: swal input type text#2336

Merged
limetech merged 1 commit into
masterfrom
fix/swal-input-type-text-visibility
Aug 14, 2025
Merged

fix: swal input type text#2336
limetech merged 1 commit into
masterfrom
fix/swal-input-type-text-visibility

Conversation

@zackspear

@zackspear zackspear commented Aug 13, 2025

Copy link
Copy Markdown
Contributor
  • Added 'swal-input-show' class to input fields in Wireless.php to ensure they are displayed correctly.
  • Modified CSS in jquery.sweetalert.css to hide default SweetAlert input fields while allowing specific ones to show (hiding was already done in legacy webgui)
  • Removed duplicated swal input styles from lower in the CSS file

Summary by CodeRabbit

  • New Features
    • Ensures only relevant fields are shown in network dialogs for a cleaner experience.
  • Bug Fixes
    • Fixed WiFi/network join/edit dialog where Username, Password, IPv4/IPv6, Gateway, and DNS fields could be hidden; all required fields now display correctly.
  • Style
    • Refined input visibility in SweetAlert dialogs to reduce clutter and improve clarity without changing existing controls (e.g., password show/hide).

- Added 'swal-input-show' class to input fields in Wireless.php to ensure they are displayed correctly.
- Modified CSS in jquery.sweetalert.css to hide default SweetAlert input fields while allowing specific ones to show (hiding was already done in legacy webgui)
@zackspear zackspear requested a review from ljm42 August 13, 2025 22:06
@coderabbitai

coderabbitai Bot commented Aug 13, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Updates the WiFi join/edit UI to add a swal-input-show class to several input fields via Wireless.php, and revises SweetAlert CSS to hide text inputs by default unless they carry this class. No server-side logic or control flow changes.

Changes

Cohort / File(s) Summary of Changes
Wireless UI input classes
emhttp/plugins/dynamix/include/Wireless.php
saveAttr() now adds swal-input-show to Username, Password, IPv4/IPv6 address, gateway, and DNS inputs. No structural or logic changes.
SweetAlert input visibility CSS
emhttp/plugins/dynamix/styles/jquery.sweetalert.css
Replaces prior SweetAlert text input styling with input[type="text"]:not(.swal-input-show){display:none;}. Removes previous broad styling and transitions; visibility now controlled per-input via class.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested labels

7.2

Suggested reviewers

  • ljm42
  • MrAungThuHtet

Poem

I twitch my whiskers, tap the keys—
A class here, a style to please.
Inputs peek where they should show,
The hidden fields now come and go.
In CSS burrows, tidy and tight,
I hop through forms—everything just right. 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the "Integrations" page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/swal-input-type-text-visibility

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ljm42 ljm42 added the 7.2 label Aug 13, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
emhttp/plugins/dynamix/include/Wireless.php (1)

202-203: Auth inputs correctly opt-in to visibility

Adding swal-input-show to Username and Password ensures they remain visible under the new SweetAlert CSS. Password didn’t strictly need the class (rule hides only text inputs), but keeping it is harmless and future-proof.

emhttp/plugins/dynamix/styles/jquery.sweetalert.css (1)

181-185: Fix typo in comment

“allow the ones we want to be show” → “allow the ones we want to be shown”.

Apply this minimal correction:

-  /* this is a hack to prevent the default SWAL input from being shown, but allow the ones we want to be show */
+  /* this is a hack to prevent the default SWAL input from being shown, but allow the ones we want to be shown */
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce9b3ab and 965a753.

📒 Files selected for processing (2)
  • emhttp/plugins/dynamix/include/Wireless.php (1 hunks)
  • emhttp/plugins/dynamix/styles/jquery.sweetalert.css (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-02T21:51:01.477Z
Learnt from: zackspear
PR: unraid/webgui#2222
File: emhttp/plugins/dynamix/styles/jquery.sweetalert.css:610-640
Timestamp: 2025-06-02T21:51:01.477Z
Learning: In the Unraid webgui codebase, SweetAlert button styling is handled through CSS inheritance from general button selectors in default-base.css rather than component-specific `.sweet-alert button` selectors. SweetAlert buttons inherit styling from the general `button`, `button[type="button"]`, `input[type="button"]`, and `a.button` selectors.

Applied to files:

  • emhttp/plugins/dynamix/styles/jquery.sweetalert.css
🧬 Code Graph Analysis (1)
emhttp/plugins/dynamix/include/Wireless.php (1)
emhttp/plugins/dynamix/include/Helpers.php (1)
  • mk_option (182-184)
🔇 Additional comments (1)
emhttp/plugins/dynamix/include/Wireless.php (1)

209-230: No built-in SweetAlert text inputs found—coverage complete

Verification results:

  • No occurrences of swal({... input: …} were detected in the codebase.
  • All custom text inputs in SweetAlert dialogs are now tagged with swal-input-show.

With no remaining built-in inputs at risk of being hidden, this change fully covers the surface area.

Comment on lines +181 to 185
/* this is a hack to prevent the default SWAL input from being shown, but allow the ones we want to be show */
input[type="text"]:not(.swal-input-show) {
display: none;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Narrow the selector to only hide the default SweetAlert input (safer scope)

As written, this hides every text input inside any SweetAlert unless it has swal-input-show. If any dialog embeds a custom text input without the new class, it will disappear.

Consider scoping to the default SweetAlert fieldset input (the library’s built-in prompt) while leaving other embedded form inputs alone. This reduces regression risk and still achieves your intent.

Proposed change:

-  input[type="text"]:not(.swal-input-show) {
+  fieldset > input[type="text"]:not(.swal-input-show) {
     display: none;
   }

Please spot-check a couple of SweetAlert dialogs that embed custom forms (beyond Wireless) to ensure their inputs remain visible after this change.


🏁 Script executed:

#!/bin/bash
set -e

echo "1. JavaScript files in emhttp/plugins/dynamix:"
find emhttp/plugins/dynamix -type f -name '*.js' || true

echo
echo "2. Occurrences of swal( with context:"
rg -n -A3 "swal\s*\(" emhttp/plugins/dynamix || true

echo
echo "3. Occurrences of html: (to spot custom form content):"
rg -n -C2 "html\s*:" emhttp/plugins/dynamix || true

Length of output: 324980


Restrict hidden inputs to SweetAlert’s built-in prompt only
We spot-checked all SweetAlert usages with custom HTML (e.g. the “Always Allow” checkbox in Wireless, progress dialogs in BodyInlineJS, etc.) and found no dialogs embedding a plain text input outside the library’s own prompt fieldset. It’s safe to scope the rule to only hide the default prompt input:

--- a/emhttp/plugins/dynamix/styles/jquery.sweetalert.css
+++ b/emhttp/plugins/dynamix/styles/jquery.sweetalert.css
@@ -181,7 +181,7 @@
   /* hide all un-intended text inputs, but show our flagged ones */
-  input[type="text"]:not(.swal-input-show) {
+  fieldset > input[type="text"]:not(.swal-input-show) {
     display: none;
   }

Please apply this change to tighten the selector and avoid accidentally hiding other form inputs.

🤖 Prompt for AI Agents
In emhttp/plugins/dynamix/styles/jquery.sweetalert.css around lines 181-185, the
current rule hides all text inputs which may unintentionally hide non-SweetAlert
inputs; narrow the selector to only target SweetAlert's built-in prompt input by
scoping the rule to the SweetAlert modal/content and the library's prompt input
class (e.g., prefix the selector with the swal modal/content class and target
the swal prompt input class) so only the built-in prompt is hidden when it lacks
the .swal-input-show class.

@limetech limetech merged commit 7ff00c2 into master Aug 14, 2025
4 checks passed
@limetech limetech deleted the fix/swal-input-type-text-visibility branch August 14, 2025 05:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants