Skip to content

Commit 5bdad42

Browse files
Fix AI feature UX issues in chart creation flow
Three UX improvements for better AI feature accessibility: 1. Image Upload Lock Icon - Fixed alignment and popup navigation - Repositioned lock overlay to top of container (40px padding) - Changed lock icon to display:block for proper centering - Added onclick handler to close popup and navigate to AI Settings in parent window 2. AI Chat Sidebar - Improved Settings/Chat section behavior - Added Settings section with conditional collapse (collapsed when API key exists) - Made Chat section grayed out when no API key configured - Fixed incorrect URL (viz-ai-settings → visualizer-ai-settings) - Added popup escape to all AI Settings links 3. Chart Creation Modal - Fixed auto-scroll behavior - Removed scrollIntoView() that was hiding image upload section - Modal now stays scrolled to top, making AI image upload visible by default Files modified: - classes/Visualizer/Render/Page/Types.php (lock icon alignment) - classes/Visualizer/Render/Sidebar.php (Settings/Chat sections) - js/frame.js (removed auto-scroll) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a31a9a8 commit 5bdad42

3 files changed

Lines changed: 23 additions & 13 deletions

File tree

classes/Visualizer/Render/Page/Types.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ protected function _renderContent() {
7878

7979
if ( $show_api_lock ) {
8080
// Show API key configuration lock (for PRO users without API keys)
81-
echo '<div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.9); border-radius: 8px; display: flex; align-items: center; justify-content: center; z-index: 10;">';
81+
echo '<div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.9); border-radius: 8px; z-index: 10; padding-top: 40px;">';
8282
echo '<div style="text-align: center; padding: 20px;">';
83-
echo '<span class="dashicons dashicons-lock" style="font-size: 48px; color: #999; margin-bottom: 10px;"></span>';
83+
echo '<span class="dashicons dashicons-lock" style="font-size: 48px; color: #999; margin-bottom: 10px; display: block;"></span>';
8484
echo '<h3 style="margin: 10px 0; color: #666;">' . esc_html__( 'AI Features - API Key Required', 'visualizer' ) . '</h3>';
8585
echo '<p style="margin: 10px 0; color: #666;">' . esc_html__( 'Configure your AI API key to use AI-powered chart creation from images.', 'visualizer' ) . '</p>';
86-
echo '<a href="' . admin_url( 'admin.php?page=visualizer-ai-settings' ) . '" class="button button-primary" style="margin-top: 10px;">';
86+
echo '<a href="' . admin_url( 'admin.php?page=visualizer-ai-settings' ) . '" class="button button-primary" style="margin-top: 10px;" onclick="if(window.parent !== window) { window.parent.location.href = this.href; return false; }">';
8787
echo esc_html__( 'Configure AI Settings', 'visualizer' );
8888
echo '</a>';
8989
echo '</div>';

classes/Visualizer/Render/Sidebar.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -864,18 +864,19 @@ protected function _renderAIConfigurationGroup() {
864864
sprintf(
865865
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
866866
esc_html__( 'Chat with AI to customize your chart. Ask questions, get suggestions, or describe what you want. The AI understands your chart type and current configuration. %1$sConfigure API keys%2$s', 'visualizer' ),
867-
'<a href="' . admin_url( 'admin.php?page=visualizer-ai-settings' ) . '" target="_blank">',
867+
'<a href="' . admin_url( 'admin.php?page=visualizer-ai-settings' ) . '" onclick="if(window.parent !== window) { window.parent.location.href = this.href; return false; }">',
868868
'</a>'
869869
)
870870
);
871871
self::_renderSectionEnd();
872872

873-
self::_renderSectionStart( esc_html__( 'Settings', 'visualizer' ), false );
874-
875873
// Check if any AI API key is configured
876874
$has_openai = ! empty( get_option( 'visualizer_openai_api_key', '' ) );
877875
$has_gemini = ! empty( get_option( 'visualizer_gemini_api_key', '' ) );
878876
$has_claude = ! empty( get_option( 'visualizer_claude_api_key', '' ) );
877+
$has_any_api_key = $has_openai || $has_gemini || $has_claude;
878+
879+
self::_renderSectionStart( esc_html__( 'Settings', 'visualizer' ), $has_any_api_key );
879880

880881
$ai_models = array();
881882
if ( $has_openai ) {
@@ -904,15 +905,19 @@ protected function _renderAIConfigurationGroup() {
904905
'<span style="color: #d63638;">' . sprintf(
905906
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
906907
esc_html__( 'No AI API keys configured. %1$sConfigure your API keys%2$s to use AI features.', 'visualizer' ),
907-
'<a href="' . admin_url( 'admin.php?page=viz-ai-settings' ) . '" target="_blank">',
908+
'<a href="' . admin_url( 'admin.php?page=visualizer-ai-settings' ) . '" onclick="if(window.parent !== window) { window.parent.location.href = this.href; return false; }">',
908909
'</a>'
909910
) . '</span>'
910911
);
911912
}
912913

913914
self::_renderSectionEnd();
914915

915-
self::_renderSectionStart( esc_html__( 'AI Chat', 'visualizer' ), true );
916+
self::_renderSectionStart( esc_html__( 'AI Chat', 'visualizer' ), $has_any_api_key );
917+
918+
if ( ! $has_any_api_key ) {
919+
echo '<div style="opacity: 0.5; pointer-events: none;">';
920+
}
916921

917922
echo '<div class="viz-section-item">';
918923
echo '<div id="visualizer-ai-chat-container" style="background: #f9f9f9; border: 1px solid #ddd; border-radius: 4px; padding: 15px; max-height: 400px; overflow-y: auto; margin-bottom: 10px;">';
@@ -943,6 +948,10 @@ protected function _renderAIConfigurationGroup() {
943948

944949
echo '</div>';
945950

951+
if ( ! $has_any_api_key ) {
952+
echo '</div>';
953+
}
954+
946955
self::_renderSectionEnd();
947956

948957
// Add upsell overlay if locked (free version)

js/frame.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
(function ($) {
1010
$(window).on('load', function(){
11-
let chart_select = $('#chart-select');
12-
if(chart_select.length > 0){
13-
// scroll to the selected chart type.
14-
$('#chart-select')[0].scrollIntoView();
15-
}
11+
// Removed auto-scroll to chart-select to keep the image upload section visible
12+
// let chart_select = $('#chart-select');
13+
// if(chart_select.length > 0){
14+
// // scroll to the selected chart type.
15+
// $('#chart-select')[0].scrollIntoView();
16+
// }
1617
});
1718

1819
$(document).ready(function () {

0 commit comments

Comments
 (0)