spawn process of node js giving error in electron app in production mode

I am developing an electron app with react and I have a python file which I want to run through main process of electron.

I am using child-process of node js to spawn the python exe(esic.exe) file. I created the python exe file using pyinstaller which runs fine in standalone mode.

const exeLocation = path.join(__dirname, 'dist/esic.exe')
const process = spawn(exeLocation, [args])

In development mode everything runs properly, main process of electron could able to spawn the process and send arguments and receive the output, but once I package the electron app using electron-builder it gives me this ENOENT code error
enter image description here

I searched about ENOENT error and found that it’s the error which indicates that the specified path for a file or directory does not exist in the filesystem so I tried to unpackage the electron build which has a app.asar file. On unpackaging the asar file I found that it contains the dist directory and there is a esic.exe file in it, so that means the electron-builder packaged the build correctly.

Now I am totally confused about why it runs in development mode but not in production mode.

Import gltf scene and create bounding boxes using javascript

I am currently developing an online browser 3d Game.
The whole collision detection should be calculated both on the server and the client to obviate hackers.

As the physics engine I decided to use rapier as it seems to be the most up to date one.
Now I need to load my game scene which I exported from blender as a .gltf file.
To display it on the client side I just use the threejs gltf loader.
However, on the server side I do not use threejs. Besides that I have to generate bounding boxes of all objects inside the scene to use it in rapier after loading the gltf file somehow.

How do I load the gltf file without threejs? How do I generate the bounding boxes? Should I maybe include the bounding boxes inside the gltf scene? Rapier does not seem to support it out of the box. I am not tied to rapier, but I would prefer it.

Multiple of ten [duplicate]

function glgm() { if(parsedAcc == 10) { accg.innerHTML = parsedAccG += 1; } }

I just need to know how to replace the 10 by “multiple of ten” so that it works every time it gets to a multiple of ten thank you.
I’m learning so I don’t know much. I’m sorry if it’s obvious.

Newcomer question; Fastify fails to start when plugin added

I am new to nodejs world and I am using Fastify while following this edx course LinuxFoundationX LFW111x on Edx
The server is running fine until I do not add a certain plugin (data-utils.js) under the plugins folder. As soon as I added it, as required by the course, the servers fails with the following error

[email protected] dev
fastify start -w -l info -P app.js

SyntaxError: Unexpected token ‘{‘
at ModuleLoader.moduleStrategy (node:internal/modules/esm/translators:167:18)
at callTranslator (node:internal/modules/esm/loader:285:14)
at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:30)
at async link (node:internal/modules/esm/module_job:76:21)

Removing the plugin “solves” the issue. The following is the plugin code, taken directly from the course site

"use strict";

import fp from "fastify-plugin";

const catToPrefix = {
  electronics: "A",
  confectionery: "B",
};

const calculateID = (idPrefix, data) => {
  const sorted = [...new Set(data.map(({ id }) => id))];
  const next = Number(sorted.pop().slice(1)) + 1;
  return ${idPrefix}${next};
};

export default fp(async function (fastify, opts) {
  fastify.decorate("mockDataInsert", function (request, category, data) {
    const idPrefix = catToPrefix[category];
    const id = calculateID(idPrefix, data);
    data.push({ id, ...request.body });
    return data
  });
});

Can you see anything that could help me?

I am a complete newcomer of Fastity and also not so strong in JS so I cannot spot what’s wrong,
What I notice is that removing the following const variable

const calculateID = (idPrefix, data) => {
  const sorted = [...new Set(data.map(({ id }) => id))];
  const next = Number(sorted.pop().slice(1)) + 1;
  return ${idPrefix}${next};
};

“fix” the problem, so the issue could be in that code fragment, but given my lack of experience I cannot see what’s wrong with it

Edit: adding backtick to the return function seems to fix the problem

`${idPrefix}${next}`

Now I am going to complete the chapter and see if it gets the desired result

Acrobat Run profiles with variables(JavaScript)

a preflight created based on acrobat,How can I set a value to the preflight before running.

var oProfile = Preflight.getProfileByName("myPreflight");
var oThermometer = app.thermometer;
var textSize = 10;
//oProfile.SetVariable("textSize",textSize); how to do?
var myPreflightResult = this.preflight(oProfile,false,oThermometer );

Volume Slider Javascript Only

So I have tried searching this and couldn’t find any material on this.

I am trying to make a volume slider for my project but can only use javascript. The only html allowed is to load the songs. Now I can make a rectangle how I want but I need to be able to click and drag one end to affect the volume of the music and make the bar shrink and grow.

I do not know enough about built-in js functions and we are not allowed to use libraries, so please I need help.

I tried to take some code that I thought would work but I quickly realised that it was for a selection box. I know someone in my class did it but they are not allowed to share snippets of code, and all I could get from them is that they used only base js and make the bar resizable and then made the volume change according to the height of the bar.

I just don’t know how to make the bar resizable and store its height.

Jest – react native – Cannot use import statement outside a module

I want to use Unit test with react native / expo
When i start them “npm test”
I get the error
SyntaxError: Cannot use import statement outside a module

import { getRandomBase64String } from 'react-native-get-random-values'

I already add this problems but skip it by usin Mock.
There i can’t skip it with Mock because this function is the center of my function

What i tried :
Different transformIgnorePatterns in package.json
Modifications of my babel.config.json
Use requiere instead
Add type=”module”

My current package.json

"jest": {
    "moduleNameMapper": {
      "\.(jpg|ico|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/mocks/fileMock.js",
      "\.(css|less|scss|sass)$": "<rootDir>/mocks/fileMock.js"
    }
  },

My current babel.config.js

module.exports = function(api) {
  api.cache(true);
  return {
    presets: ['babel-preset-expo'],
  };
};

Thank you for your help

Users may not be connecting to the same websocket – django channels

I’m developing a chat feature using django channels. when a message is sent, It gets created on the server side and I think it’s being broadcasted. in my consumer I’m adding both the sender and receiver to the same group. on the client side I’m using javascript to get the sender and receiver IDs and connect them to the websocket. but when user A sends a message to user B. even though the message object is created and sent, it doesn’t appear for User B. I’ve verified that both users are connected to the websocket and there are no errors. but i think the issue might be that they are not connecting to the same websocket but I’m not sure why this is happening. also I’m new to django channels and javascript.

Javascript

let senderId = null;
let receiverId = null;

document.addEventListener('DOMContentLoaded', function () {
  const chatLog = document.querySelector('#chat-conversation-content');
  const messageInput = document.querySelector('#chat-message-input');
  const chatMessageSubmit = document.querySelector('#chat-message-submit');
  const activeChat = document.querySelector('.fade.tab-pane.show');

  let chatSocket = null;

  function connectToChat(sender_id, receiver_id) {
      const wsURL = 'ws://' + window.location.host + '/ws/messenger/' + sender_id + '/' + receiver_id + '/';
      try {
          chatSocket = new WebSocket(wsURL);

          chatSocket.onopen = function (e) {
              console.log('WebSocket connection established.');
          };

          chatSocket.onmessage = function (e) {
              try {
                  const data = JSON.parse(e.data);

                  const messageElement = document.createElement('div');
                  if (data.sender_id === senderId) {
                      // Render message for sender
                      messageElement.innerHTML = `
                          <div class="d-flex justify-content-end text-end mb-1">
                              <div class="w-100">
                                  <div class="d-flex flex-column align-items-end">
                                      <div class="bg-primary text-white p-2 px-3 rounded-2">${data.message}</div>
                                      <div class="small my-2">${data.timestamp}</div>
                                  </div>
                              </div>
                          </div>
                      `;
                  } else {
                      messageElement.innerHTML = `
                          <div class="d-flex mb-1">
                              <div class="flex-shrink-0 avatar avatar-xs me-2">
                                  <img class="avatar-img rounded-circle" src="${data.message}" alt="">
                              </div>
                              <div class="flex-grow-1">
                                  <div class="w-100">
                                      <div class="d-flex flex-column align-items-start">
                                          <div class="bg-light text-secondary p-2 px-3 rounded-2">${data.message}</div>
                                          <div class="small my-2">${data.timestamp}</div>
                                      </div>
                                  </div>
                              </div>
                          </div>
                      `;
                  }

                  chatLog.appendChild(messageElement);
              } catch (error) {
                  console.error('Error processing received message:', error);
              }
          };

          chatSocket.onerror = function (error) {
              console.error('WebSocket error:', error);
          };

          chatSocket.onclose = function (e) {
              console.log('WebSocket connection closed.');
          };
      } catch (error) {
          console.error('WebSocket connection error:', error);
      }
  }

  document.querySelectorAll('.friend-name').forEach(function (nameElement) {
    
      nameElement.addEventListener('click', function (e) {
          e.preventDefault();
          senderId = this.getAttribute('data-sender-id');
          receiverId = this.getAttribute('data-receiver-id');
          if (chatSocket !== null && chatSocket.readyState === WebSocket.OPEN) {
              chatSocket.close();
          }
          connectToChat(senderId, receiverId);
      });
  });
  
  function sendMessage() {
    const message = messageInput.value.trim();
    if (message !== '') {
        chatSocket.send(JSON.stringify({
            'message': message,
            'sender_id': senderId,
            'receiver_id': receiverId,
        }));
        messageInput.value = '';
    }
}

  chatMessageSubmit.addEventListener('click', sendMessage);
});

Html

{% for friend in user_friends.friends.all %}
<li data-bs-dismiss="offcanvas">
<a href="#chat-{{ forloop.counter }}" class="nav-link text-start friend-name" id="chat-{{ forloop.counter }}-tab" data-sender-id="{{ user.id }}" data-receiver-id="{{ friend.id }}" data-bs-toggle="pill" role="tab">
  <div class="d-flex">
    <div class="flex-shrink-0 avatar avatar-story me-2 status-online">
      <img class="avatar-img rounded-circle" src="{{ friend.profile.profile_picture.url }}">
    </div>
    <div class="flex-grow-1 d-block">
      <h6 class="mb-0 mt-1">{{ friend.get_full_name|title }}</h6>
      <div class="small text-secondary"></div>
    </div>
  </div>
</a>
</li>
{% endfor %}



<div class="col-lg-8 col-xxl-9">
  <div class="card card-chat rounded-start-lg-0 border-start-lg-0">
    <div class="card-body h-100">
      <div class="tab-content py-0 mb-0 h-100" id="chatTabsContent">
        <!-- Conversation item START -->
        {% for friend in user_friends.friends.all %}
        <div class="fade tab-pane show h-100" id="chat-{{ forloop.counter }}" role="tabpanel" aria-labelledby="chat-{{ forloop.counter }}-tab">
          <!-- Top avatar and status START -->
          <div class="d-sm-flex justify-content-between align-items-center">
            <div class="d-flex mb-2 mb-sm-0">
              <div class="flex-shrink-0 avatar me-2">
                <img class="avatar-img rounded-circle" src="{{ friend.profile.profile_picture.url }}" alt="">
              </div>
              <div class="d-block flex-grow-1">
                <h6 class="mb-0 mt-1">{{ friend.get_full_name|title }}</h6>
                <div class="small text-secondary"><i class="fa-solid fa-circle text-success me-1"></i>Online</div>
              </div>
            </div>
            <div class="d-flex align-items-center">
              <div class="dropdown">
                <a class="icon-md rounded-circle btn btn-primary-soft me-2 px-2" href="#" id="chatcoversationDropdown" role="button" data-bs-toggle="dropdown" data-bs-auto-close="outside" aria-expanded="false"><i class="bi bi-three-dots-vertical"></i></a>               
                <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="chatcoversationDropdown">
                  <li><a class="dropdown-item" href="#"><i class="bi bi-check-lg me-2 fw-icon"></i>Mark as read</a></li>
                  <li><a class="dropdown-item" href="{% url "core:view-profile" username=friend.username %}"><i class="bi bi-person-check me-2 fw-icon"></i>View profile</a></li>
                  <li><a class="dropdown-item" href="#"><i class="bi bi-trash me-2 fw-icon"></i>Delete chat</a></li>
                  <li class="dropdown-divider"></li>
                </ul>
              </div>
            </div>
          </div>
          <!-- Top avatar and status END -->
          <hr>
          <!-- Chat conversation START -->
          <div class="chat-conversation-content overflow-auto custom-scrollbar" id="chat-conversation-content">
            <!-- Chat time -->
            <div class="text-center small my-2">Jul 16, 2022, 06:15 am</div>
            <!-- Chat message left -->
            {% for message in messages %}
              {% if message.sender == request.user %}
                <div class="d-flex justify-content-end text-end mb-1">
                  <div class="w-100">
                    <div class="d-flex flex-column align-items-end">
                      <div class="bg-primary text-white p-2 px-3 rounded-2">{{ message.content }}</div>
                      <div class="small my-2">{{ message.timestamp|date:"g:i A" }}</div>

                    </div>
                  </div>
                </div>
              {% else %}
                <div class="d-flex mb-1">
                  <div class="flex-shrink-0 avatar avatar-xs me-2">
                    <img class="avatar-img rounded-circle" src="{{ message.sender.profile.profile_picture.url }}" alt="">
                  </div>
                  <div class="flex-grow-1">
                    <div class="w-100">
                      <div class="d-flex flex-column align-items-start">
                        <div class="bg-light text-secondary p-2 px-3 rounded-2">{{ message.content }}</div>
                        <div class="small my-2">{{ message.timestamp|date:"g:i A" }}</div>
                      </div>
                    </div>
                  </div>
                </div>
              {% endif %}
            {% endfor %}
          </div>
          <!-- Chat conversation END -->
        </div>
        {% endfor %}
        <!-- Conversation item END -->
      </div>
    </div>
    <div class="card-footer">
      <div class="d-sm-flex align-items-end">
        <textarea id="chat-message-input" class="form-control mb-sm-0 mb-3" data-autoresize placeholder="Type a message" rows="1"></textarea>
        <button class="btn btn-sm btn-secondary-soft ms-2"><i class="fa-solid fa-paperclip fs-6"></i></button>
        <button id="chat-message-submit" type="submit" class="btn btn-sm btn-primary ms-2"><i class="fa-solid fa-paper-plane fs-6"></i></button>
      </div>
    </div>
  </div>
</div>

Consumers

class ChatConsumer(AsyncWebsocketConsumer):
async def connect(self):
    self.sender_id = self.scope['url_route']['kwargs']['sender_id']
    self.receiver_id = self.scope['url_route']['kwargs']['receiver_id']
    self.room_group_name = f'chat_{self.sender_id}_{self.receiver_id}'

    await self.channel_layer.group_add(
        self.room_group_name,
        self.channel_name
    )

    await self.accept()

async def receive(self, text_data):
    text_data_json = json.loads(text_data)
    message = text_data_json['message']
    sender_id = text_data_json['sender_id']
    receiver_id = text_data_json['receiver_id']
    
    sender_profile_picture = await sync_to_async(self.get_profile_picture)(sender_id)
    receiver_profile_picture = await sync_to_async(self.get_profile_picture)(receiver_id)

    message_obj = await sync_to_async(Message.objects.create)(
        sender_id=sender_id,
        receiver_id=receiver_id,
        content=message
    )

    await self.channel_layer.group_send(
        self.room_group_name,
        {
            'type': 'chat_message',
            'message': message,
            'sender_id': sender_id,
            'receiver_id': receiver_id,
            'sender_profile_picture': sender_profile_picture,
            'receiver_profile_picture': receiver_profile_picture,
            'timestamp': message_obj.timestamp.strftime('%I:%M %p')
        }
    )

async def disconnect(self, close_code):
    await self.channel_layer.group_discard(
        self.room_group_name,
        self.channel_name
    )

async def chat_message(self, event):
    message = event['message']
    sender_id = event['sender_id']
    receiver_id = event['receiver_id']
    sender_profile_picture = event['sender_profile_picture']
    receiver_profile_picture = event['receiver_profile_picture']
    timestamp = event['timestamp']

    await self.send(text_data=json.dumps({
        'message': message,
        'sender_id': sender_id,
        'receiver_id': receiver_id,
        'sender_profile_picture': sender_profile_picture,
        'receiver_profile_picture': receiver_profile_picture,
        'timestamp': timestamp
    }))

def get_profile_picture(self, user_id):
    return Profile.objects.get(user__id=user_id).profile_picture.url

Url routing

websocket_urlpatterns = [
    path('ws/messenger/<int:sender_id>/<int:receiver_id>/', ChatConsumer.as_asgi())
]

Why isn’t the contex value updated until the state’s value is?

I’m using a context to generate tab like elements:

import { createContext } from "react"

let TABS = createContext({
    tabs:[],
    setTabs:(tab)=>{
        const allTabs = this.tabs;
        this.tabs = [...allTabs,tab];
    }
});

export default TABS;

And I’m using the sidebar menu items to add to the tabs. Also I’m using a state to change sidebar menu’s content:


const DUMMY_DATA = {
  "paymentAndRecieve": {
    actions: [
      {
        id: 1,
        title: <IntlMessages id="sidebar.paymentAndRecieve.actions.recieve" />,
        url: "/paymentAndRecieve/actions/recieve",
      },
      {
        id: 2,
        title: <IntlMessages id="sidebar.paymentAndRecieve.actions.pay" />,
        url: "/paymentAndRecieve/actions/pay",
      },
    ],
    lists: [
      {
        id: 4,
        title: <IntlMessages id="sidebar.paymentAndRecieve.actions.recieve" />,
        url: "/paymentAndRecieve/lists/recieve",
      },
      {
        id: 3,
        title: <IntlMessages id="sidebar.paymentAndRecieve.actions.pay" />,
        url: "/paymentAndRecieve/lists/pay",
      },
    ],
  },
  "accounting": {
    actions: [
      {
        id: 1,
        title: <IntlMessages id="sidebar.accounting.actions.recieve" />,
        url: "/paymentAndRecieve/actions/recieve",
      },
      {
        id: 2,
        title: <IntlMessages id="sidebar.accounting.actions.pay" />,
        url: "/paymentAndRecieve/actions/pay",
      },
    ],
    lists: [
      {
        id: 4,
        title: <IntlMessages id="sidebar.accounting.actions.recieve" />,
        url: "/paymentAndRecieve/lists/recieve",
      },
      {
        id: 3,
        title: <IntlMessages id="sidebar.accounting.actions.pay" />,
        url: "/paymentAndRecieve/lists/pay",
      },
    ],
  },
};
const Panel = Collapse.Panel;

const SubMenu = Menu.SubMenu;
const MenuItemGroup = Menu.ItemGroup;

const SidebarContent = ({ sidebarCollapsed, setSidebarCollapsed }) => {
  const { navStyle, themeType } = useSelector(({ settings }) => settings);
  const pathname = useSelector(({ common }) => common.pathname);
  const { tabs, setTabs } = useContext(TABS);
  const [category, setCategory] = useState([]);
  const history = useHistory();

  

  function addTab({ title, id, url }) {
    
    let tabLength = tabs.find((tab) => tab.id === id);
    if (!tabLength) {
     
      setTabs([...tabs  ,{title: title, id: id, url: url }]);
    }
    console.log(tabs)
    history.push(url);
  }
  function changeCategory(id) {
    const actions = (
      <MenuItemGroup key="actions" className="gx-menu-group">
        <Collapse accordion>
          <Panel showArrow={false} header="عملیات">
            {DUMMY_DATA[id].actions.map((option) => {
              return (
                <Menu.Item key={option.id}>
                  <button
                    className={classes.link_option}
                    onClick={() => {
                      addTab(option);
                    }}
                  >
                    {option.title}
                  </button>
                </Menu.Item>
              );
            })}
          </Panel>
        </Collapse>
      </MenuItemGroup>
    );
    const lists = (
      <MenuItemGroup key="lists" className="gx-menu-group">
        <Collapse accordion>
          <Panel showArrow={false} header="فهرست ها">
            {DUMMY_DATA[id].lists.map((option) => {
              return (
                <Menu.Item key={option.id}>
                  <button
                    className={classes.link_option}
                    onClick={() => {
                      addTab(option);
                    }}
                  >
                    {option.title}
                  </button>
                </Menu.Item>
              );
            })}
          </Panel>
        </Collapse>
      </MenuItemGroup>
    );
    setCategory([actions, lists]);
  }
  
  const getNoHeaderClass = (navStyle) => {
    if (
      navStyle === NAV_STYLE_NO_HEADER_MINI_SIDEBAR ||
      navStyle === NAV_STYLE_NO_HEADER_EXPANDED_SIDEBAR
    ) {
      return "gx-no-header-notifications";
    }
    return "";
  };

  const selectedKeys = pathname.substr(1);
  const defaultOpenKeys = selectedKeys.split("/")[1];

  console.log(category);
  return (
    <>
      <SidebarLogo
        sidebarCollapsed={sidebarCollapsed}
        setSidebarCollapsed={setSidebarCollapsed}
      />
      <div className="gx-sidebar-content">
        <div
          className={`gx-sidebar-notifications ${getNoHeaderClass(navStyle)}`}
        >
          <UserProfile />
          <AppsNavigation />
        </div>
        <CustomScrollbars
          className={`gx-layout-sider-scrollbar ${classes.scrollbar}`}
        >
          <Menu
            defaultOpenKeys={[defaultOpenKeys]}
            selectedKeys={[selectedKeys]}
            theme={themeType === THEME_TYPE_LITE ? "lite" : "dark"}
            mode="inline"
          >
              {category}

          </Menu>
        </CustomScrollbars>
        <div className={classes.categories}>
          <button
            className={classes.category}
            onClick={() => {
              changeCategory("accounting");
            }}
          >
            accounting
          </button>
          <button
            className={classes.category}
            onClick={() => {
              changeCategory("paymentAndRecieve");
            }}
          >
            Payment & Receive
          </button>
          
        </div>
      </div>
    </>
  );
};

export default React.memo(SidebarContent);

and this is how I show my tabs:

const OpentTabs = () => {
  const history= useHistory();
  const {tabs,setTabs} = useContext(TABS);


  function removeTab(id){
    const currentTab = tabs.find(tab=> tab.id===id);
    setTabs(tabs.filter(tab => tab.id!== id));
    if(currentTab.url===window.location.pathname){
      console.log(window.location.pathname === tabs[tabs.length-1].url? tabs[tabs.length-2].url:tabs[tabs.length-1].url);
      if(tabs.length>1){
        history.push(window.location.pathname === tabs[tabs.length-1].url? tabs[tabs.length-2].url:tabs[tabs.length-1].url);
      }else{
        history.push('/home')
      }

    }
    
  }


  const  tabList = tabs.map((tab) => {
    return (
      <li
        key={tab.id}
        className={classes.tab}
      >
        
        <i className="icon icon-close" onClick={()=>{removeTab(tab.id)}}></i> 
        <NavLink id={tab.id} to={tab.url} className={isActive =>
          isActive
            ? classes.active
            : classes.inactive}>
          {tab.title}
        </NavLink>
      </li>
    );
  });

  return <ul className={classes.ul}>{tabList}</ul>;
};

export default OpentTabs;

But my problem is that when I open a new tab the context value is emptied and the filled therefor it doesn’t keep the previously opened tabs, That’s until a new category is chosen, then it will keep the previous tabs and open a new one But even then it will only change the last tab. what should I do?

have tried using another state and pouring that state into the context but it just made the webpage to breakdown.

CSS: Expand/collapse animation in `flex` accordion when container size is fixed

Good afternoon,

I have a need to create HTML/CSS/JS accordion. Requirements: accordion container’s height must be fixed (100% body’s height) and if panel’s content overflows, scrollbar must be inside panel’s content div and not inside accordion container itself!
I have created a pen: https://codepen.io/lotrmj/pen/bGJEzrp to show general idea. Everything works as intended, but there is no animation…

Is it possible to create animation for expand/collapse action similar to:
https://vuetifyjs.com/en/components/expansion-panels/#variant ?
Or is it impossible as panel headers and corresponding contents do not have fixed height?
If it is possible, could somebody of you help me a bit?

I have done that before with jQuery UI library and it was working, but I am searching for more modern solutions/libraries..

I tried looking for examples but didn’t find any with similar problem.

<template>
  <div id="nav">
      <template v-for="i in 5">
        <div class="panel-header">
          <span>PANEL {{i}}</span>
          <button @click="expandOrCollapse(i)">{{i == activePanel ? "Collapse" : "Expand"}}</button>
        </div>
        <div class="panel-content" v-if="i == activePanel">
          <div class="content">
            Very long panel {{i}} content with scrollbar...
          </div>
        </div>
      </template>
  </div>
  <div id="main">MAIN DIV</div>
</template>

<script>
export default {
  data() {
    return {
      activePanel: 2
    };
  },
  methods: {
    expandOrCollapse(i) {
      if (i == this.activePanel) {
        this.activePanel = undefined;
      } else {
        this.activePanel = i;
      }
    }
  }
};
</script>

<style>
  html, body {
    height: 100%;
    margin: 0;
  }
  body {
    display: flex;
  }
  #app {
    flex-grow: 1;
    display: flex;
  }
  #nav {
   width: 400px;
   border-right: 1px solid #ccc;
   overflow: auto;
   display: flex;
   flex-direction: column;
  }
  #main {
   flex-grow: 1;
   display: flex;
   align-items: center;
   justify-content: center;
  }
  .panel-header, .panel-content {
    border-bottom: 1px solid #ddd;
    padding: 5px;
  }
  .panel-header span {
    padding-right: 3px;
  }
  .panel-content {
    overflow: auto;
    flex-grow: 1;
  }
  .content {
    height: 1000px;
  }
</style>

Expand/collapse animation in `flex` accordion when container size is fixed

Good afternoon,

I have a need to create HTML/CSS/JS accordion. Requirements: accordion container’s height must be fixed (100% body’s height) and if panel’s content overflows, scrollbar must be inside panel’s content div and not inside accordion container itself!
I have created a pen: https://codepen.io/lotrmj/pen/bGJEzrp to show general idea. Everything works as intended, but there is no animation…

Is it possible to create animation for expand/collapse action similar to:
https://vuetifyjs.com/en/components/expansion-panels/#variant ?
Or is it impossible as panel headers and corresponding contents do not have fixed height?
If it is possible, could somebody of you help me a bit?

I have done that before with jQuery UI library and it was working, but I am searching for more modern solutions/libraries..

I tried looking for examples but didn’t find any with similar problem.

<template>
  <div id="nav">
      <template v-for="i in 5">
        <div class="panel-header">
          <span>PANEL {{i}}</span>
          <button @click="expandOrCollapse(i)">{{i == activePanel ? "Collapse" : "Expand"}}</button>
        </div>
        <div class="panel-content" v-if="i == activePanel">
          <div class="content">
            Very long panel {{i}} content with scrollbar...
          </div>
        </div>
      </template>
  </div>
  <div id="main">MAIN DIV</div>
</template>

<script>
export default {
  data() {
    return {
      activePanel: 2
    };
  },
  methods: {
    expandOrCollapse(i) {
      if (i == this.activePanel) {
        this.activePanel = undefined;
      } else {
        this.activePanel = i;
      }
    }
  }
};
</script>

<style>
  html, body {
    height: 100%;
    margin: 0;
  }
  body {
    display: flex;
  }
  #app {
    flex-grow: 1;
    display: flex;
  }
  #nav {
   width: 400px;
   border-right: 1px solid #ccc;
   overflow: auto;
   display: flex;
   flex-direction: column;
  }
  #main {
   flex-grow: 1;
   display: flex;
   align-items: center;
   justify-content: center;
  }
  .panel-header, .panel-content {
    border-bottom: 1px solid #ddd;
    padding: 5px;
  }
  .panel-header span {
    padding-right: 3px;
  }
  .panel-content {
    overflow: auto;
    flex-grow: 1;
  }
  .content {
    height: 1000px;
  }
</style>

React Binding issue

i need to bind api rsponse data to the textboxes:

                            <label htmlFor="jobTitle" className="form-label lbl">Job Title:</label>
                            <input type="text" id="jobTitle" name="jobTitle" className="form-input"/>
                        </div>
                        <div className="form-group">
                            <label htmlFor="Salary" className="form-label lbl">Salary:</label>
                            <input type="text" id="Salary" name="Salary" className="form-input"/>
                        </div>
                        
                            document.getElementById('#jobTitle').value = response.data.jobTitle;
        document.querySelector('#Salary').value = response.data.salary;
        
        but it shows error:
        
        TypeError: Cannot set properties of null (setting 'value')

want to know a method to access the textboxes to bind the data

I want to show svg icon for each option of

my requirement is as simple as below image

enter image description here

As you can see in the above image my basic requirement is

  1. Popover select dropdown
  2. Before label i want to show svg icon

Here is what i have tried : https://stackblitz.com/edit/fkdeuw?file=src%2Fcomponents%2FExample.vue

    <ion-select
    aria-label="Fruit"
    interface="popover"
    placeholder="Select fruit"
  >
    <ion-select-option value="apples">
      <svg
        xmlns="http://www.w3.org/2000/svg"
        width="16"
        height="16"
        fill="currentColor"
        class="bi bi-house"
        viewBox="0 0 16 16"
      >
        <path
          d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5z"
        />
      </svg>
      Apples
    </ion-select-option>
    <ion-select-option value="oranges">
      <svg
        xmlns="http://www.w3.org/2000/svg"
        width="16"
        height="16"
        fill="currentColor"
        class="bi bi-star"
        viewBox="0 0 16 16"
      >
        <path
          d="M2.866 14.85c-.078.444.36.791.746.593l4.39-2.256 4.389 2.256c.386.198.824-.149.746-.592l-.83-4.73 3.522-3.356c.33-.314.16-.888-.282-.95l-4.898-.696L8.465.792a.513.513 0 0 0-.927 0L5.354 5.12l-4.898.696c-.441.062-.612.636-.283.95l3.523 3.356-.83 4.73zm4.905-2.767-3.686 1.894.694-3.957a.56.56 0 0 0-.163-.505L1.71 6.745l4.052-.576a.53.53 0 0 0 .393-.288L8 2.223l1.847 3.658a.53.53 0 0 0 .393.288l4.052.575-2.906 2.77a.56.56 0 0 0-.163.506l.694 3.957-3.686-1.894a.5.5 0 0 0-.461 0z"
        />
      </svg>
      Oranges
    </ion-select-option>
    <ion-select-option value="bananas">
      <svg
        xmlns="http://www.w3.org/2000/svg"
        width="16"
        height="16"
        fill="currentColor"
        class="bi bi-asterisk"
        viewBox="0 0 16 16"
      >
        <path
          d="M8 0a1 1 0 0 1 1 1v5.268l4.562-2.634a1 1 0 1 1 1 1.732L10 8l4.562 2.634a1 1 0 1 1-1 1.732L9 9.732V15a1 1 0 1 1-2 0V9.732l-4.562 2.634a1 1 0 1 1-1-1.732L6 8 1.438 5.366a1 1 0 0 1 1-1.732L7 6.268V1a1 1 0 0 1 1-1"
        />
      </svg>
      Bananas
    </ion-select-option>
  </ion-select>